答案1
这并不是万无一失的。它不能分页(当然,tabular
原贴作者的方法也不能)。此外,还有其他一些邪恶的可能性,即最后一个括号的位置取决于顶部文本或底部文本是否最长(如 中设置的那样)\hbox
,这并没有考虑到实际的齐平对齐\parbox
可能会在未被发现的情况下逆转该结论。
最后,...
必须手动在空白行上添加,使用\\...\\...
等等。
编辑以使用\linewidth
而不是\textwidth
,以便在multicols
环境中正常工作。
\documentclass{article}
\usepackage{stackengine,tabto,multicol}
\newlength\parboxdepth
\newcommand\variate[2]{\bgroup%
\setbox0=\hbox{#1}%
\setbox2=\hbox{#2}%
\ifdim\wd0>\wd2\relax%
\let\endbraceB\relax%
\else%
\let\endbraceT\relax%
\fi
$\Bigl\{$\tabto*{0pt}\edef\myindent{\TabPrevPos}\renewcommand\stacktype{L}%
\setbox0=\hbox{\parbox[t]{\linewidth}{\baselineskip=2\baselineskip\relax%
\tabto{\myindent}#2\endbraceB}}%
\setbox2=\hbox{\parbox[t]{\linewidth}{\baselineskip=2\baselineskip\relax%
\tabto{\myindent}#1\endbraceT}}%
\ifdim\dp2>\dp0\relax\parboxdepth=\dp2\relax\else\parboxdepth=\dp0\relax\fi%
\raisebox{-.5\dimexpr\Lstackgap\relax}{\stackon{\copy0}{\copy2}}%
\ifdim\parboxdepth>\baselineskip\relax\vspace{-.66\baselineskip}\else%
\vspace{-\baselineskip}\fi\vspace{-\parskip}%
\par%
\leavevmode\tabto{\myfinalindent}%
\rule[-\baselineskip]{0pt}{2\baselineskip}%
\egroup}
\def\endbraceT{\raisebox{-.25\dimexpr\Lstackgap}{$\Bigr\}$}%
\tabto*{0pt}\xdef\myfinalindent{\TabPrevPos}}
\def\endbraceB{\raisebox{+.25\dimexpr\Lstackgap}{$\Bigr\}$}%
\tabto*{0pt}\xdef\myfinalindent{\TabPrevPos}}
%\textwidth 3.5in\relax% FOR NON-MULTICOLS TEST
\setstackgap{L}{.8\baselineskip}% \variate BASELINE SKIP; CAN BE VARIED TO SUIT
\begin{document}
\begin{multicols}{2}
Depending on \variate{Thing A}{Thing B} I want to end my statement on
\variate{Conclusion C}{Conclusion D}.
Using \variate{tabular}{tabularx} gives me \variate{no line breaks for
statements exceeding the multicols column-width}{automated line-breaks\\...}
but \variate{enables variable column-width.\\...}{uses whole column width
for short statements.}
All in all, \variate{I want my cases to start in line, break like this at the
end of the multicols-column and end at a variable length in-line}{...\\...
\\...}.
\end{multicols}
\end{document}
在某个multicols
环境中,如果列中断发生在参数的中间,仍然可能存在问题\variate
,如下所示:
注释掉multicols
,并\textwidth
设置为3.5in。