我有一个tabbing
环境,我想在一些文本行旁边添加一条水平线,直到页面末尾。\hrulefill
由于 ,所以无法工作tabbing
。\noindent\rule{x}{y}
将放置一条线,但由于文本行在不同的位置结束,因此具有定义长度的线也会如此。
\documentclass{article}
\begin{document}
\begin{tabbing}
\textbf{whatever short} \= \noindent\rule{20cm}{0.5pt} \\
2005-2014 \> doesn't matter\\
\> \textit{doesn't matter}\\
2011-2012 \> doesn't matter\\
\> \textit{doesn't mattter}\\
\textbf{whaaaaaaateeeeeeeever long} \noindent\rule{13cm}{0.5pt} \\
from 10/2012 \> first one\\
\> \textit{2nd one}\\
07/2015 - 12/2015 \> first one\\
\> \textit{2nd one}
\end{tabbing}
\end{document}
答案1
您可以使用 tikz 和 tikzmark。它需要两次编译。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usetikzlibrary{calc}
\begin{document}
\begin{tabbing}
\begin{tikzpicture}[overlay,remember picture]
\path (0,0)--++(\textwidth,0) coordinate (yline);
\draw (pic cs:a) -- ({pic cs:a} -| yline);
\end{tikzpicture}%
\textbf{whatever short} \= \tikzmark{a} \\
2005-2014 \> doesn't matter\\
\> \textit{doesn't matter}\\
2011-2012 \> doesn't matter\\
\> \textit{doesn't mattter}\\
\begin{tikzpicture}[overlay,remember picture]
\path (0,0)--++(\textwidth,0) coordinate (yline);
\draw (pic cs:b) -- ({pic cs:b} -| yline);
\end{tikzpicture}%
\textbf{whaaaaaaateeeeeeeever long} \tikzmark{b} \\
from 10/2012 \> first one\\
\> \textit{2nd one}\\
07/2015 - 12/2015 \> first one\\
\> \textit{2nd one}
\end{tabbing}
\end{document}
答案2
tabbing
如果单元格超出标签点,则不会抱怨。
\documentclass{article}
\usepackage{tabularx}
\newcommand{\single}[1]{%
\textbf{#1}\ \=\kill
\makebox[\textwidth][s]{\textbf{#1} \hrulefill}}
\begin{document}
\begin{tabbing}
\single{whatever short} \\
2005-2014 \> doesn't matter\\
\> \textit{doesn't matter}\\
2011-2012 \> doesn't matter\\
\> \textit{doesn't mattter}\\
\single{whaaaaaaateeeeeeeever long} \\
from 10/2012 \> first one\\
\> \textit{2nd one}\\
07/2015 -- 12/2015 \> first one\\
\> \textit{2nd one}
\end{tabbing}
\end{document}