我需要创建类似目录的内容,多个页码右对齐,如下图所示,文本将位于左侧,页码将不规则地左对齐
我尝试过但未能以正确的方式获取单独的页码,如何获取此输出?
梅威瑟:
\documentclass{book}
\makeatletter
\newdimen\figurecontwidth%
\newskip\enspacefigurecontentwidth\enspacefigurecontentwidth=8.5pt%
\def\figurepunct#1{\gdef\@figurepunct{#1}}\figurepunct{}%
%%
\newcommand\figmax[1]{\setbox\tempbox\hbox{\figurecontentnumfont#1\@figurepunct}%
\global\figurecontwidth\wd\tempbox%
%\global\advance\figurecontwidth4pt
}%
%%
\def\figurenumberline#1{\hb@xt@\@tempdima{\hbox to \figurecontwidth{\hfill#1\@figurepunct}\hfill}}%
%%
%%
\newcommand\l@cases[2]{\def\@tocrmarg{3em}%%
\overfullrule\z@%
\let\numberline\figurenumberline%
\setlength\@tempdima{\figurecontwidth}%
\advance\@tempdima\enspacefigurecontentwidth%
\begingroup%
\baselineskip11pt
\parindent\z@%
\rightskip\@tocrmarg%
\advance\rightskip by\z@\@plus2cm%
\parfillskip-\@tocrmarg%
\leavevmode%
\advance\leftskip\@tempdima%
\hskip-\leftskip%
\noindent{\small#1}%
\nobreak\leaders\hbox{$\m@th\mkern\@dotsep mu\hbox{.}\mkern\@dotsep mu$}\hfill\nobreak%
{\hfil\small#2}\par%
\penalty\@highpenalty%
\endgroup%
\vspace{3pt}
}%
\makeatother
\begin{document}
\chapter*{Table of Legislation}
\contentsline{cases}{Abortion Act 1967}{150}{}
\contentsline{cases}{Access to Justice Act 1999}{155}{}
\contentsline{cases}{Brussels EEC Convention on Jurisdiction and the Enforcement of Judgments
in Civil and Commercial Matters 1968 (European Jurisdiction Convention)}{160}{}
\contentsline{cases}{\protect\numberline{2.4}Plot of the intensity of black-body radiation at a single frequency deep in the infrared
against temperature from a paper submitted to Annalen der Physik in February 1901
by Heinrich Rubens and Ferdinand Kurlbaum (1901). The figure clearly shows that
for long wavelengths the intensity varies linearly with the temperature, in agreement
with both the Planck law and the Rayleigh-Jeans law (which fails for shorter wave-
lengths). The data, however, are in sharp disagreement with the Wien law (Gearhart
2002, p. 180; Stone 2013, p. 9).}{5.87–5.88, 6.67,
7.111, 8.109, 9.61, 11.87, 14.96,
15.95, 17.104, 19.124, 21.75,
22.78, 23.231–23.232, 23.236,
23.238, 23.252, 24.45}{}
\end{document}
答案1
这是“概念证明”。我把它集成到目录中交给你。基本上,我将文本排版为 raggedright,并优先考虑较短的最后一行,以便它能为前导符和行号的第一部分留出足够的空间(但不保证)。然后我取消该段落最后一行的装箱,删除右侧的填充空间,然后使用此行、前导符和行号构建一个新段落,将 raggedleft 设置为左边距约为0.3\linewidth
。当然,你可以玩弄这个数字。它使用了很多低级 TeX 技巧,其中一些可以转换为官方 LaTeX 代码(例如使用)。如果你不小心,它也很容易被破坏,给出错误的间距等。顺便说一句,\setlength
它也适用于。\twocolumn
\documentclass{book}
\newcommand\leftrightparagraph[2]{%
\begingroup\vskip0pt
\parskip=0pt\parindent=0pt
% \box0 and \box2 are scratch box registers
\setbox2=\vbox{\rightskip=0pt plus 2em
\parfillskip=0.5\linewidth plus 0.2\linewidth minus 0.2\linewidth
\strut#1\strut\par}%
\unvbox2\setbox0=\lastbox
\noindent\hbox{\strut\unhbox0\unskip\unskip}% remove \parfillskip and \rightskip
\rightskip=0pt \leftskip=0pt plus 0.2\linewidth\parfillskip=0pt
\hangafter 1 \hangindent 0.3\linewidth
\leaders\hbox{\hbox{. }}\hfill
#2\par\endgroup
}
\begin{document}
\chapter*{Table of Legislation}
\leftrightparagraph{Abortion Act 1967}{150}
\leftrightparagraph{Access to Justice Act 1999}{155}
\leftrightparagraph{Brussels EEC Convention on Jurisdiction and the Enforcement of Judgments
in Civil and Commercial Matters 1968 (European Jurisdiction Convention)}{160}
\leftrightparagraph{Plot of the intensity of black-body radiation at a single frequency deep in the infrared
against temperature from a paper submitted to Annalen der Physik in February 1901
by Heinrich Rubens and Ferdinand Kurlbaum (1901). The figure clearly shows that
for long wavelengths the intensity varies linearly with the temperature, in agreement
with both the Planck law and the Rayleigh-Jeans law (which fails for shorter wave-
lengths). The data, however, are in sharp disagreement with the Wien law (Gearhart
2002, p.~180; Stone 2013, p.~9).}{5.87–5.88, 6.67,
7.111, 8.109, 9.61, 11.87, 14.96,
15.95, 17.104, 19.124, 21.75,
22.78, 23.231–23.232, 23.236,
23.238, 23.252, 24.45}
\end{document}