我有一个文件,里面有一些连续的表格,每个月一个。listoftables
如果将每个表格条目列在单独的行上,则会占用太多空间。我可以使用multicols
两列输出整个表格列表,但我不想对所有表格都这样做。我怎样才能在表格列表中为特定范围的表格获得三列输出?
我尝试获取的表格列表的输出(最好是第一个):
1.1 Table . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 January . . . 2 1.3 February . . 2 1.4 March . . . . 2
1.5 April . . . . 3 1.6 May . . . . . 3 1.7 June . . . . 3
1.8 July . . . . 3
1.9 More tables . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1 More tables from next chapter . . . . . . . . . . . . . . . 4
或者
1.1 Table . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 January . . . 2 1.5 April . . . . 3 1.8 July . . . . 3
1.3 February . . 2 1.6 May . . . . . 3
1.4 March . . . . 2 1.7 June . . . . 3
1.9 More tables . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1 More tables from next chapter . . . . . . . . . . . . . . . 4
我目前使用addtocontents
“几乎”的黑客解决方案可行,但除了对齐和点间距的明显问题外,如果我想在两列、三列或四列布局之间切换,它并不灵活。更重要的是,它不是自动的。
另外,我不确定如何隐藏特定表的表条目列表。我尝试caption*
使用caption
包,但没有成功。我猜这与类有关memoir
。
\documentclass[oneside]{memoir}
\usepackage{hyperref}
\usepackage{multicol}
\newcommand{\threecoltab}[3]{%
\begin{tabularx}{\linewidth}{XXX} #1 & #2 & #3 \end{tabularx}}
\newcommand{\spaceddotfill}[0]{{} \dotfill \hspace{1.5em}}
\newcommand{\lotcontent}[6]{\noindent%
\hyperref[#2]{#1} \spaceddotfill{} \pageref{#2} \hspace{1em}%
\hyperref[#4]{#3} \spaceddotfill{} \pageref{#4} \hspace{1em}%
\hyperref[#6]{#5} \spaceddotfill{} \pageref{#6} \newline}
\begin{document}
\listoftables
% \begin{multicols}{2} \listoftables \end{multicols}
\chapter{Records}
\begin{table}[htp] \caption{Table} \label{tab:t1} \end{table}
\begin{table}[htp] \caption{January} \label{tab:m1} \end{table}
\begin{table}[htp] \caption{February} \label{tab:m2} \end{table}
\begin{table}[htp] \caption{March} \label{tab:m3} \end{table}
\begin{table}[htp] \caption{April} \label{tab:m4} \end{table}
\begin{table}[htp] \caption{May} \label{tab:m5} \end{table}
\begin{table}[htp] \caption{June} \label{tab:m6} \end{table}
\begin{table}[htp] \caption{July} \label{tab:m7} \end{table}
\begin{table}[htp] \caption{More tables} \label{tab:t2} \end{table}
\addtocontents{lot}{\noindent
\hyperref[tab:m1]{January} \spaceddotfill{} \pageref{tab:m1} \hspace{1em}
\hyperref[tab:m2]{February} \spaceddotfill{} \pageref{tab:m2} \hspace{1em}
\hyperref[tab:m3]{March} \spaceddotfill{} \pageref{tab:m3} \newline}
\addtocontents{lot}{\lotcontent{January}{tab:m1}{February}{tab:m2}{March}{tab:m3}}
\addtocontents{lot}{\lotcontent{April}{tab:m4}{May}{tab:m5}{June}{tab:m6}}
% \addtocontents{lot}{\lotcontent{July}{tab:m7}{}{}{}{}}
\addtocontents{lot}{\noindent
\hyperref[tab:m7]{July} \spaceddotfill{} \pageref{tab:m7} }
%\addtocontents{lot}{\threecoltab{\hyperref[tab:m1]{January}}{\hyperref[tab:m2]{February}}{\hyperref[tab:m3]{March}}}
\chapter{Data}
\begin{table}[htp] \caption{Table from next chapter} \label{tab:t3} \end{table}
\end{document}
答案1
\documentclass[oneside]{memoir}
\usepackage{hyperref}
\usepackage{multicol}
\let\oldcontentsline\contentsline
%non hyperref version
\def\mcontentsline#1#2#3#4{%
\ifvmode\noindent\else\unskip\hspace{1em plus 2pt}\fi
\hbox{\vbox{\hsize=\dimexpr(\hsize-#1em+1em)/#1\relax
\oldcontentsline{#2}{#3}{#4}}}}
\def\mcontentsline#1#2#3#4#5{%
\ifvmode\noindent\else\unskip\hspace{1em plus 2pt}\fi
\hbox{\vbox{\hsize=\dimexpr(\hsize-#1em+1em)/#1\relax
\oldcontentsline{#2}{#3}{#4}{#5}}}}
\protected\def\ltcols#1{%
\ifnum#1=1
\par\let\contentsline\oldcontentsline
\else
\par\def\contentsline{\mcontentsline{#1}}%
\fi}
\begin{document}
\listoftables
\chapter{Records}
\begin{table}[htp] \caption{Table} \label{tab:t1} \end{table}
\begin{table}[htp] \addtocontents{lot}{\ltcols{3}}\caption{January}\label{tab:m1} \end{table}
\begin{table}[htp] \caption{February} \label{tab:m2} \end{table}
\begin{table}[htp] \caption{March} \label{tab:m3} \end{table}
\begin{table}[htp] \caption{April} \label{tab:m4} \end{table}
\begin{table}[htp] \caption{May} \label{tab:m5} \end{table}
\begin{table}[htp] \caption{June} \label{tab:m6} \end{table}
\begin{table}[htp] \caption{July} \label{tab:m7} \end{table}
\begin{table}[htp] \addtocontents{lot}{\ltcols{1}}\caption{More tables} \label{tab:t2} \end{table}
\chapter{Data}
\begin{table}[htp] \caption{Table from next chapter} \label{tab:t3} \end{table}
\end{document}