是否有一个好的方法可以在表格格式中包含多个图形?
我希望它看起来类似于以下模型(请原谅我糟糕的 MS Paint 技能),并且愿意使用任何必要的软件包。如果有一种很好的方法可以像我一样将列标记为行(和、和、和) include
,我会很高兴。a
b
1
2
3
答案1
以下通过定义新的\fixedlabel
标签方案来实现。修复与标签相关的\fixedlabel{<lab>}{<tag>}
标签(类似于标签机制<tag>
<lab>
\tag
amsmath
)。
% http://tex.stackexchange.com/questions/52189/including-table-of-figures
\documentclass{article}
\makeatletter
\def\fixedlabel#1#2{%
\@bsphack%
\protected@write\@auxout{}%
{\string\newlabel{#1}{{#2}{\thepage}}}%
\@esphack}
\makeatother
\begin{document}
\begin{table}[ht]
\centering
\begin{tabular}{c@{\quad}cc}
& a & b \\
1 & \rule[-25pt]{100pt}{50pt}\fixedlabel{block1a}{1a}
& \rule[-25pt]{100pt}{50pt}\fixedlabel{block1b}{1b} \\ \\
2 & \rule[-25pt]{100pt}{50pt}\fixedlabel{block2a}{2a}
& \rule[-25pt]{100pt}{50pt}\fixedlabel{block2b}{2b} \\ \\
3 & \rule[-25pt]{100pt}{50pt}\fixedlabel{block3a}{3a}
& \rule[-25pt]{100pt}{50pt}\fixedlabel{block3b}{3b}
\end{tabular}
\caption{This is a caption.}\label{figtab}
\end{table}
See, for example, \ref{block1a} and~\ref{block2b} in Table~\ref{figtab}.
\end{document}
Ahyperref
兼容版本\fixedlabel
由以下公式给出:
\def\fixedlabel#1#2{%
\@bsphack
\begingroup
\@onelevel@sanitize\@currentlabelname
\edef\@currentlabelname{%
\expandafter\strip@period\@currentlabelname\relax.\relax\@@@%
}%
\phantomsection%
\protected@write\@auxout{}{%
\string\newlabel{#1}{%
{#2}%
{\thepage}%
{#2}%
{\@currentHref}{}%
}%
}%
\endgroup
\@esphack
}
答案2
这是一个可能的解决方案,使用禁忌包裹:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tabu}
\usepackage{caption,subcaption}
\newcounter{tmp}
% \MyIm{<figure name>}{<label>}
\newcommand\MyIm[2]{%
\captionof*{subfigure}{}
\includegraphics[width=4cm,height=2cm]{#1}
\captionof{subfigure}{}\label{#2}%
}
\begin{document}
\begin{center}
\setcounter{tmp}{\thefigure}
\captionsetup[subfigure]{labelformat=empty}
\begin{tabu}{>{\refstepcounter{figure}\thefigure\setcounter{subfigure}{0}}l%
X[c,m]X[c,m]}
\multicolumn{1}{l}{\setcounter{figure}{0}} & a & b \\[-20pt]
& \MyIm{name1}{a} & \MyIm{name2}{b} \\[-30pt]
& \MyIm{name3}{c} & \MyIm{name4}{d} \\[-30pt]
& \MyIm{name5}{e} & \MyIm{name6}{f}
\end{tabu}\setcounter{figure}{\thetmp}
\end{center}
\ref{a} \ref{b} \ref{c} \ref{d} \ref{e} \ref{f}
\end{document}
一些评论:
在表之前使用计数器来存储计数器的值,然后在表结束时恢复
tmp
计数器的值figure
figure
这副标题包用于为每个图形提供一个空标题;这允许轻松分配用于
\label
交叉引用。该解决方案与配合使用
hyperref
;唯一要做的就是加载hyperref
和hypcap
:\usepackage{hyperref} \usepackage{hypcap}