我一直尝试将缩略图添加为 {longtabu} 中的列条目。
LaTeX - 插入缩略图,其中包含指向附录中所含全尺寸图像的链接 前来救援。
现在,按照上述答案中的说明插入的缩略图可以完美运行,但问题是,当我使用相同的缩略图作为表格条目时,与该缩略图相对应的多个重复图像会插入到附录中。
想知道解决这种重复的方法。
编辑:所要求的 MWE 在此处。我希望这能满足需要。
\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{longtable, tabu}
% set up a counter for links
\newcounter{thumbnail}
% to store the images for later
\newbox\savedimgs
\setbox\savedimgs\vbox{}
% thumbnail and appendix command
\newcommand{\thumbnailandappendix}[1]{
% #1: name of image
\refstepcounter{thumbnail}
% set up hypertarget before the thumbnail
\hypertarget{small\thethumbnail}{}
% input thumbnail version
\hyperlink{big\thethumbnail}{\includegraphics[width=1cm,height=1cm]{#1}}
% save the big version for later
\global\setbox\savedimgs\vbox{
\unvbox\savedimgs
\bigskip
\filbreak
\noindent
\hypertarget{big\thethumbnail}{}
\hyperlink{small\thethumbnail}{\includegraphics[width=10cm,height=10cm]{#1}}}
}
\begin{document}
%works fins when used normally like this:
%\thumbnailandappendix{image.jpg}
%use of thumbnail in longtable that is leading to duplicate entries in appendix
\clearpage
\section{Images}
\begin{center}
\begin{longtabu}{ | X[-1, l] |X[-1, l] |}
\caption{Images Table}\\ \hline
\hspace{0pt}FILENAME & \hspace{0pt}IMAGE REFERENCE \\ \hline \hline \endhead
image.jpg & \thumbnailandappendix{image.jpg}\\ \hline
\end{longtabu}
\end{center}
\clearpage
\appendix
\section{Full-size image}
\unvbox\savedimgs
\end{document}
}
谢谢。
PS 我是本网站的新会员,因此没有足够的信誉点数来直接评论上述链接并提问;因此我以新问题的形式提出这个问题。请原谅我偏离了任何规则,以防万一。
答案1
与问题无关的问题longtable
在于,在试运行中多次设置tabu
X
像原始列这样的列以获得正确的列宽。tabularx
X
为了避免多次写入标签和其他内容,代码会\write
在试运行期间禁用一些其他命令,这样您就可以检测到这一点,并且直到最后一次运行才制作缩略图。
\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{longtable, tabu}
% set up a counter for links
\newcounter{thumbnail}
% to store the images for later
\newbox\savedimgs
\setbox\savedimgs\vbox{}
% thumbnail and appendix command
\newcommand{\thumbnailandappendix}[1]{
% #1: name of image
\refstepcounter{thumbnail}
% set up hypertarget before the thumbnail
\hypertarget{small\thethumbnail}{}
% input thumbnail version
\hyperlink{big\thethumbnail}{\includegraphics[width=1cm,height=1cm]{#1}}
% save the big version for later
\global\setbox\savedimgs\vbox{
\unvbox\savedimgs
\bigskip
\filbreak
\noindent
\hypertarget{big\thethumbnail}{}
\hyperlink{small\thethumbnail}{\includegraphics[width=10cm,height=10cm]{#1}}}
}
\let\realwrite\write
\begin{document}
%works fins when used normally like this:
%\thumbnailandappendix{image.jpg}
%use of thumbnail in longtable that is leading to duplicate entries in appendix
\clearpage
\section{Images}
\begin{center}
\begin{longtabu}{ | X[-1, l] |X[-1, l] |}
\caption{Images Table}\\ \hline
\hspace{0pt}FILENAME & \hspace{0pt}IMAGE REFERENCE \\ \hline \hline \endhead
image.jpg & \ifx\write\realwrite\thumbnailandappendix{example-image}\fi\\ \hline
\end{longtabu}
\end{center}
\clearpage
\appendix
\section{Full-size image}
\unvbox\savedimgs
\end{document}