下面是我试图将数字放入的代码longtable
。我想知道如何减少数字(列)之间的间距以及如何将数字拉伸到两个边距?
\documentclass[letter]{article}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{ltcaption}
\usepackage{duckuments}% for variety
\usepackage[showframe]{geometry}
\begin{document}
\noindent\rule{\textwidth}{20\baselineskip}
\renewcommand{\LTcaptype}{figure}%
\begin{longtable}{@{}ccc@{}}
\caption{Empirical Regularities During Currency Crises \label{fig: cc}}
\endhead
\includegraphics[width=.31\textwidth]{example-image-duck} &
\includegraphics[width=.31\textwidth]{example-image-duck} &
\includegraphics[width=.31\textwidth]{example-image-duck}\\
%
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} \\
%
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} \\
%
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} \\
%
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} \\
\end{longtable}
\end{document}
答案1
我建议定义您自己的环境,以免在文档中充斥着本应是本地的指令。
\documentclass{article}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{ltcaption}
\usepackage{duckuments}% for variety
\usepackage[pass,showframe]{geometry}
\newenvironment{longfigure}[2][]{%
% #1 (optional) is arbitrary code to be executed before the longtable
% #2 is the column specification
\renewcommand{\LTcaptype}{figure}%
\setlength{\LTleft}{0pt}%
#1%
\begin{longtable}{#2}
}{\end{longtable}\addtocounter{figure}{-1}}
\begin{document}
\noindent\rule{6pt}{20\baselineskip}
\begin{longfigure}[\setlength{\tabcolsep}{0.01\textwidth}]{@{}ccc@{}}
\caption{Empirical Regularities During Currency Crises \label{fig:cc}}
\endfirsthead
\caption*{Empirical Regularities During Currency Crises (continued)}
\endhead
\includegraphics[width=0.32\textwidth]{example-image-duck} &
\includegraphics[width=0.32\textwidth]{example-image-duck} &
\includegraphics[width=0.32\textwidth]{example-image-duck}\\
%
\includegraphics[width=0.32\textwidth]{example-image-duck} &
\includegraphics[width=0.32\textwidth]{example-image-duck} &
\includegraphics[width=0.32\textwidth]{example-image-duck} \\
%
\includegraphics[width=0.32\textwidth]{example-image-duck} &
\includegraphics[width=0.32\textwidth]{example-image-duck} &
\includegraphics[width=0.32\textwidth]{example-image-duck} \\
%
\includegraphics[width=0.32\textwidth]{example-image-duck} &
\includegraphics[width=0.32\textwidth]{example-image-duck} &
\includegraphics[width=0.32\textwidth]{example-image-duck} \\
%
\includegraphics[width=0.32\textwidth]{example-image-duck} &
\includegraphics[width=0.32\textwidth]{example-image-duck} &
\includegraphics[width=0.32\textwidth]{example-image-duck} \\
\end{longfigure}
\end{document}
的神奇因素0.01
来自\tabcolsep
于我们有三列,每列占 的 32% \textwidth
,所以我们需要将剩余的空间分成四部分。
使用的修改subfigure
:
\documentclass{article}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{ltcaption}
\usepackage{duckuments}% for variety
\usepackage{subcaption}
\usepackage[pass,showframe]{geometry}
\newenvironment{longfigure}[2][]{%
% #1 (optional) is arbitrary code to be executed before the longtable
% #2 is the column specification
\renewcommand{\LTcaptype}{figure}%
\expandafter\def\csname @captype\endcsname{figure}%
\setcounter{subfigure}{0}%
\setlength{\LTleft}{0pt}%
#1%
\begin{longtable}{#2}
}{\end{longtable}\addtocounter{figure}{-1}}
\begin{document}
\noindent\rule{6pt}{20\baselineskip}
\begin{longfigure}[\setlength{\tabcolsep}{0.01\textwidth}]{@{}ccc@{}}
\caption{Empirical Regularities During Currency Crises \label{fig:cc}}
\endfirsthead
\caption*{Empirical Regularities During Currency Crises (continued)}
\endhead
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} \\
%
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} \\
%
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} \\
%
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} \\
%
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} \\
%
\end{longfigure}
\end{document}
由于芭芭拉·比顿 (barbara beeton) 评论了尴尬的间距,这里有一个解决方法。
\documentclass{article}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{ltcaption}
\usepackage{duckuments}% for variety
\usepackage{subcaption}
\usepackage[pass,showframe]{geometry}
\newenvironment{longfigure}[2][]{%
% #1 (optional) is arbitrary code to be executed before the longtable
% #2 is the column specification
\renewcommand{\LTcaptype}{figure}%
\expandafter\def\csname @captype\endcsname{figure}%
\setcounter{subfigure}{0}%
\setlength{\LTleft}{0pt}%
#1%
\begin{longtable}{#2}
}{\end{longtable}\addtocounter{figure}{-1}}
\begin{document}
\noindent\rule{6pt}{20\baselineskip}
\begin{longfigure}[{%
\AtEndEnvironment{subfigure}{\vspace{4pt}}%
\captionsetup[subfigure]{aboveskip=1pt}%
\setlength{\tabcolsep}{0.01\textwidth}%
}]{@{}ccc@{}}
\caption{Empirical Regularities During Currency Crises \label{fig:cc}}
\endfirsthead
\caption*{Empirical Regularities During Currency Crises (continued)}
\endhead
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} \\
%
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} \\
%
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} \\
%
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} \\
%
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.32\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} \\
%
\end{longfigure}
\end{document}
答案2
通过使用tabullarray
包:
\documentclass[letter]{article}
\usepackage{graphicx}
\usepackage{tabularray}
\usepackage{duckuments}% for variety
\usepackage[showframe]{geometry}
\usepackage{lipsum}
\begin{document}
\lipsum[1-2]
\begingroup
\setkeys{Gin}{width=\linewidth}
\begin{longtblr}[
caption = {My caption},
label = {my-label}
]{colspec={@{} XXX @{}}}
\includegraphics{example-image-duck} &
\includegraphics{example-image-duck} &
\includegraphics{example-image-duck}\\
%
\includegraphics{example-image-duck} &
\includegraphics{example-image-duck} &
\includegraphics{example-image-duck} \\
%
\includegraphics{example-image-duck} &
\includegraphics{example-image-duck} &
\includegraphics{example-image-duck} \\
%
\includegraphics{example-image-duck} &
\includegraphics{example-image-duck} &
\includegraphics{example-image-duck} \\
%
\includegraphics{example-image-duck} &
\includegraphics{example-image-duck} &
\includegraphics{example-image-duck} \\
\end{longtblr}
\endgroup
\end{document}
附录:
关于 OP 评论,在 中longtable
,longtblr
在非figure
浮动环境中,向插入的图像添加子标题并不是直接的(据我所知,\captionof
子图环境的宏不存在;如果有人否认我会很高兴),所以下面建议使用肮脏的技巧,通过命令在本地组中longtablr
模拟子标题编号\captionup{figure}{...}
。代码应该是不言自明的。
\documentclass{article}
\usepackage{graphicx}
\usepackage[skip=1ex, font=small, labelfont=bf]{caption}
\usepackage{tabularray}
\UseTblrLibrary{counter,varwidth} % <===
\begin{document}
\begingroup
\captionsetup[figure]{aboveskip=-2ex, belowskip=1ex, name=}
\renewcommand\thefigure{(\alph{figure})}
\setkeys{Gin}{width=\linewidth}
\begin{longtblr}[
caption = {Mylong table width images},
label = {my-label}
]{colspec = {@{} XXX @{}},
measure = vbox,
rowsep = 0pt,
}
% table body
\includegraphics{example-image-duck} &
\includegraphics{example-image-duck} &
\includegraphics{example-image-duck} \\
\captionof{subfigure}{Sub figure A}\label{subfig:a} &
\captionof{figure}{Sub figure B}\label{subfig:b} &
\captionof{figure}{Sub figure C}\label{subfig:c} \\
\includegraphics{example-image-duck} &
\includegraphics{example-image-duck} &
\includegraphics{example-image-duck} \\
\captionof{figure}{Sub figure D}\label{subfig:d} &
\captionof{figure}{Sub figure E}\label{subfig:e} &
\captionof{figure}{Sub figure F}\label{subfig:f}
\end{longtblr}
\setcounter{figure}{1} % so far set manually, for correct numbering of the next figure
\endgroup
\begin{figure}[ht]\centering
\includegraphics[width=0.5\linewidth]{example-image}
\caption{Next figure}
\label{fig:2}
\end{figure}
See sub-figures \ref{subfig:a}, \ref{subfig:f} in figure \ref{my-label} and figure \ref{fig:2}
\end{document}
答案3
以下代码确保longtable
环境中的材料占据文本块的整个宽度。
\documentclass[letter]{article}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{ltcaption} % for \LTcaptype macro
\usepackage{duckuments} % for variety
\usepackage{geometry}
\begin{document}
\hrule % just to illustrate width of textblock
\begingroup % localize scope of the next few instructions
\setlength\tabcolsep{0pt}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\renewcommand{\LTcaptype}{figure}
\begin{longtable}{@{\extracolsep{\fill}} lcr } % make table occupy full width
\caption{Empirical regularities during currency crises}
\label{fig:cc}\\
\endhead
\includegraphics[width=.31\textwidth]{example-image-duck} &
\includegraphics[width=.31\textwidth]{example-image-duck} &
\includegraphics[width=.31\textwidth]{example-image-duck} \\
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} \\
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} \\
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} \\
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} &
\includegraphics[width=.3\textwidth]{example-image-duck} \\
\end{longtable}
\endgroup
\end{document}
附录回答 OP 的后续问题,“是否可以为每个图额外添加 [a] 子标题?”——简短回答:“是”。稍长的回答:您需要将每个图封装在一个subfigure
环境中并提供合适的\caption
指令(并加载subcaption
包)。此时,继续使用包的机制可能没有什么意义longtable
;相反,只需将子图嵌入普通figure
环境中并通过指令将它们水平分离即可\hfill
。
以下截图分别显示了第一页的前两行和第二页的子图的最后两行。观察代码加载包alphalph
并运行
\renewcommand\thesubfigure{\alphalph{\value{subfigure}}}
为了切换到子图的“扩展字母”编号。
...
\documentclass{article}
\usepackage{graphicx}
\usepackage{duckuments}
\usepackage[letterpaper]{geometry}
\usepackage{subcaption} % <-- for 'subfigure' environment
\usepackage{alphalph} % extended alphabetical 'numbering'
\renewcommand\thesubfigure{\alphalph{\value{subfigure}}}
\begin{document}
\begin{figure}[p!] % 1st full page of subfigures
\setkeys{Gin}{width=\linewidth}
\caption{Empirical regularities during currency crises}
\label{fig:cc}
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck} \end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}
\medskip
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck} \end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}
\medskip
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck} \end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}
\medskip
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck} \end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}
\medskip
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck} \end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}
\end{figure}
\begin{figure}[p!] % 2nd full page of subfigures
\setkeys{Gin}{width=\linewidth}
\ContinuedFloat
\caption{Empirical regularities during currency crises, continued}
\label{fig:cc}
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck} \label{duck:a}
\end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck} \end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}
\medskip
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck} \end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck} \label{duck:f}
\end{subfigure}
\medskip
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck} \end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}
\medskip
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck} \end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}
\medskip
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck} \end{subfigure}\hfill
\begin{subfigure}{0.31\textwidth}
\includegraphics{example-image-duck}
\caption{A duck}
\end{subfigure}
\end{figure}
\end{document}
答案4
以下基于xltabular
而不是的代码longtable
可以作为起点。图像之间的水平间距可以通过更改 的值来调整\tabcolsep
。
\documentclass[letter]{article}
\usepackage{graphicx}
\usepackage{xltabular}
\usepackage{ltcaption}
\usepackage{duckuments}% for variety
\usepackage[showframe]{geometry}
\begin{document}
\noindent\rule{\textwidth}{20\baselineskip}
\renewcommand{\LTcaptype}{figure}%
{\setlength{\tabcolsep}{2pt}
\begin{xltabular}{\linewidth}{@{}XXX@{}}
\caption{Empirical Regularities During Currency Crises \label{fig: cc}}
\endhead
\includegraphics[width=\linewidth]{example-image-duck} &
\includegraphics[width=\linewidth]{example-image-duck} &
\includegraphics[width=\linewidth]{example-image-duck}\\
%
\includegraphics[width=\linewidth]{example-image-duck} &
\includegraphics[width=\linewidth]{example-image-duck} &
\includegraphics[width=\linewidth]{example-image-duck} \\
%
\includegraphics[width=\linewidth]{example-image-duck} &
\includegraphics[width=\linewidth]{example-image-duck} &
\includegraphics[width=\linewidth]{example-image-duck} \\
%
\includegraphics[width=\linewidth]{example-image-duck} &
\includegraphics[width=\linewidth]{example-image-duck} &
\includegraphics[width=\linewidth]{example-image-duck} \\
%
\includegraphics[width=\linewidth]{example-image-duck} &
\includegraphics[width=\linewidth]{example-image-duck} &
\includegraphics[width=\linewidth]{example-image-duck} \\
\end{xltabular}}
\end{document}