我对 LaTeX 还很陌生。在 MWE 中,我需要标题和额外信息文本永不换行。我需要根据需要换行小细节,同时充分利用空间。我认为如果左列宽度自动设置为未换行的文本内容宽度,那么一切都应该按预期工作。
实际文本将由 Python 脚本定期生成,因此,如果可能的话,我需要它在没有人工干预的情况下工作。并且还可以与目录中的正常分段等配合使用。
我并没有完全依赖 paracol,但与我尝试过的其他解决方案(例如 tabularx 等)相比,我更接近所需的结果。我在网上找到的一些解决方案似乎有效直到我包含了 \section 然后中断。
我觉得这应该比我做的要容易?
\documentclass[12pt,letterpaper]{scrartcl}
\usepackage[english]{babel}
\usepackage{paracol}
\begin{document}
\setlength{\columnseprule}{0.4pt}
% set 3.9in automatically, rather than manually
\setcolumnwidth{3.9in, \fill}
\begin{paracol}{2}
\section{Header That Goes Here (Longer)}
{\bfseries\large Extra info Goes Here}
\switchcolumn
\raggedleft
{\footnotesize Small details go here}
\end{paracol}
\clearpage
\setlength{\columnseprule}{0.4pt}
% set 4.6in automatically, rather than manually
\setcolumnwidth{4.6in, \fill}
\begin{paracol}{2}
\section{Header That Goes Here}
{\bfseries\large Extra info Goes Here (Sometimes is a bit longer)}
\switchcolumn
\raggedleft
{\footnotesize Small details go here}
\end{paracol}
\clearpage
\setlength{\columnseprule}{0.4pt}
% set 3.9in automatically, rather than manually
\setcolumnwidth{3.9in, \fill}
\begin{paracol}{2}
\section{Header That Goes Here (Longer)}
{\bfseries\large Extra info Goes Here}
\switchcolumn
\raggedleft
{\footnotesize Small details go here, and these are sometimes longer}
\end{paracol}
\end{document}
答案1
您可以使用 tabularx,但左侧文本太长,无法换行......
\documentclass[12pt,letterpaper]{scrartcl}
\usepackage[english]{babel}
\usepackage{tabularx}
\newcommand\zsec[3]{%
\par
\bigskip
\noindent
\begin{tabularx}{\linewidth}{@{}l|>{\raggedleft\arraybackslash}X@{}}%
\large\sffamily\bfseries\refstepcounter{section}\thesection. #1&\\[5pt]
\mbox{\bfseries\large#2}&\footnotesize \vspace*{-30pt} #3\end{tabularx}\par}
\begin{document}
\zsec
{Header That Goes Here (Longer)}
{Extra info Goes Here}
{Small details go here}
\zsec
{Header That Goes Here}
{Extra info Goes Here (Sometimes is a bit longer)}
{Small details go here}
\zsec
{Header That Goes Here (Longer)}
{Extra info Goes Here}
{Small details go here, and these are sometimes longer}
\end{document}