标记表格中的所有数字

标记表格中的所有数字

我找到了这个代码这里并且我想知道是否有人知道如何标记所有图形以便能够在文中引用它们并显示例如:“在图 1A 中......”

在此处输入图片描述

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{float}

\begin{document}

\begin{figure} [H]
\centering
\begin{tabular}{cccc}
\includegraphics[width=0.3\textwidth]{example-image-a} &
\includegraphics[width=0.3\textwidth]{example-image-b} &
\includegraphics[width=0.3\textwidth]{example-image-c} \\
\textbf{(a)}  & \textbf{(b)} & \textbf{(c)}  \\[6pt]
\end{tabular}
\begin{tabular}{cccc}
\includegraphics[width=0.3\textwidth]{example-image-a} &
\includegraphics[width=0.3\textwidth]{example-image-b} \\
\textbf{(d)}  & \textbf{(e)}  \\[6pt]
\end{tabular}
\caption{ \textbf{(a)} Some text
\textbf{(b)} Some text
\textbf{(c)} Some text
\textbf{(d)} Some text
\textbf{(e)} Some text}
\label{fig:Name}
\end{figure}

\end{document}

答案1

如果你可以控制图片及其标签,那么你绝对应该使用问题答案中描述的方法如何创建、添加标题、标记和引用子图?

如果这五幅图像及其标题是您不想剖析的单幅图像,您可以\extralabel{labelname}{subnumber}在序言中定义一个命令:

\makeatletter
\newcommand\extralabel[2]{{\edef\@currentlabel{\@currentlabel#2}\label{#1}}}
\makeatother

以后就可以参考labelname\ref

\documentclass{article}
\makeatletter
\newcommand\extralabel[2]{{\edef\@currentlabel{\@currentlabel#2}\label{#1}}}
\makeatother
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\begin{tabular}{cccc}
\includegraphics[width=0.3\textwidth]{example-image-a} &
\includegraphics[width=0.3\textwidth]{example-image-b} &
\includegraphics[width=0.3\textwidth]{example-image-c} \\
\textbf{(a)}  & \textbf{(b)} & \textbf{(c)}  \\[6pt]
\end{tabular}
\begin{tabular}{cccc}
\includegraphics[width=0.3\textwidth]{example-image-a} &
\includegraphics[width=0.3\textwidth]{example-image-b} \\
\textbf{(d)}  & \textbf{(e)}  \\[6pt]
\end{tabular}
\caption{ \textbf{(a)} Some text
\textbf{(b)} Some text
\textbf{(c)} Some text
\textbf{(d)} Some text
\textbf{(e)} Some text}
\label{fig:Name}
\extralabel{fig:Name:a}{(a)}
\extralabel{fig:Name:b}{(b)}
\extralabel{fig:Name:c}{(c)}
\extralabel{fig:Name:d}{(d)}
\extralabel{fig:Name:e}{(e)}
\end{figure}

See subfigures \ref{fig:Name:a}, \ref{fig:Name:b}, \ref{fig:Name:c}, \ref{fig:Name:d}, \ref{fig:Name:e}.


\end{document}

在此处输入图片描述

答案2

如果您可以控制这五张图片及其标题,那么您可以让subcaption包处理子标题和子标签。

\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}
\begin{document}
\begin{figure}
  \centering  
\begin{tabular}{ccc}
  \subcaptionbox{\label{fig:Name:a}}{\includegraphics[width=0.3\textwidth]{example-image-a}} &
  \subcaptionbox{\label{fig:Name:b}}{\includegraphics[width=0.3\textwidth]{example-image-b}} &
  \subcaptionbox{\label{fig:Name:c}}{\includegraphics[width=0.3\textwidth]{example-image-c}}
\end{tabular}
\medskip

\begin{tabular}{cc}
  \subcaptionbox{\label{fig:Name:d}}{\includegraphics[width=0.3\textwidth]{example-image-a}} &
  \subcaptionbox{\label{fig:Name:e}}{\includegraphics[width=0.3\textwidth]{example-image-c}}
\end{tabular}
\medskip

\caption{ \textbf{(a)} Some text \ref{fig:Name:b}
\textbf{(b)} Some text
\textbf{(c)} Some text
\textbf{(d)} Some text
\textbf{(e)} Some text}
\label{fig:Name}
\end{figure}

See subfigures \ref{fig:Name:a}, \ref{fig:Name:b}, \ref{fig:Name:c}, \ref{fig:Name:d}, \ref{fig:Name:e}.

\end{document}

在此处输入图片描述

相关内容