![bigdelim 和多行文本](https://linux22.com/image/292458/bigdelim%20%E5%92%8C%E5%A4%9A%E8%A1%8C%E6%96%87%E6%9C%AC.png)
我有一张表格,其中有多行通用标签。bigdelim
我使用括号来给出解释。我的解释一行文字太多,所以我想将其拆分成多行。但是,我不知道如何启用换行符(最好是自动换行,如果没有其他方法,则手动换行)。我的 MWE:
\documentclass{scrbook}
\usepackage{multirow}
\usepackage{bigdelim}
\begin{document}
\begin{tabular}{l p{8cm}}
\hline
One & \rdelim]{3}{*}[And here we have some long text, which I want to wrap over multiple lines please. Is that possible?] \\
Two \\
Three \\
\hline
\end{tabular}
\end{document}
目前结果:
[编辑] 应用评论中的建议并将文本的括号从 更改为[
后{
,我得到以下结果:
[edit2] 感谢您的建议!然而,在尝试时,我发现了以下限制,这使得无法按照建议实现它们(如果 MWE 太小,请原谅):
- 我需要分组的行数有偶数/奇数,给定的解决方案仅适用于奇数。
- 括号的长度会根据文本量而增长。有时我只输入少量文本,这意味着括号不会跨越所有必要的行。
有什么办法可以解决这个问题吗?
答案1
我真的不知道这个的目的是什么,但是这里有一个解决方案:
\documentclass[draft]{scrbook}
\usepackage{calc}
\usepackage{multirow}
\usepackage{bigdelim}
\begin{document}
\begin{tabular}{l p{8cm}}
\hline
One &
\rdelim]{3}{*}[\parbox{8cm-\tabcolsep-\widthof{$\Bigg]$}}{
And here we have some long text, which I want to wrap
over multiple lines please. Is that possible?}] \\
Two \\
Three \\
\hline
\end{tabular}
\end{document}
更简单地说,没有multirow
:
\documentclass[draft]{scrbook}
\usepackage{array}
\begin{document}
\begin{tabular}{l m{8cm}}
\hline
$\kern-\nulldelimiterspace\left.\begin{tabular}{@{}l@{}}
One \\
Two \\
Three \\
\end{tabular}\right]$ &
And here we have some long text, which I want to wrap
over multiple lines please. Is that possible? \\
\hline
\end{tabular}
\end{document}
当然,宏中可以隐藏一些东西。
\documentclass[draft]{scrbook}
\usepackage{array}
\newcommand{\bracketedright}[1]{%
$\kern-\nulldelimiterspace\left.\begin{tabular}{@{}l@{}}
#1
\end{tabular}\right]$%
}
\begin{document}
\begin{tabular}{l m{8cm}}
\hline
\bracketedright{
One \\
Two \\
Three
} &
And here we have some long text, which I want to wrap
over multiple lines please. Is that possible? \\
\hline
\end{tabular}
\end{document}
答案2
作为替代方案,以下内容如何(我还提供了拉伸分隔符以匹配左侧而不是右侧构造的可能性):
\documentclass{scrbook}
\begin{document}
\begin{tabular}{l p{8cm}}
\hline
One & \raisebox{-\normalbaselineskip}[0pt][0pt]{$\left]\parbox{\dimexpr8cm-1em}{And here we have some long text,
which I want to wrap over multiple lines please. Is that possible?}\right.\kern-\nulldelimiterspace$} \\
Two \\
Three \\
\hline
\end{tabular}
\bigskip
\begin{tabular}{l p{8cm}}
\hline
One & \raisebox{-1.5\normalbaselineskip}[0pt][0pt]{$\left]\parbox{\dimexpr8cm-1em}{And here we have some long text,
which I want to wrap over multiple lines please. Is that possible?}\right.\kern-\nulldelimiterspace$} \\
Two \\
Three \\
Four \\
\hline
\end{tabular}
\bigskip
\begin{tabular}{l p{8cm}}
\hline
One & \raisebox{-2\normalbaselineskip}[0pt][0pt]{$\left]\parbox{\dimexpr8cm-1em}{And here we have some long text,
which I want to wrap over multiple lines please. Is that possible?}\right.\kern-\nulldelimiterspace$} \\
Two \\
Three \\
Four \\
Five \\
\hline
\end{tabular}
\bigskip
\begin{tabular}{l p{8cm}}
\hline
One & \raisebox{-2\normalbaselineskip}[0pt][0pt]{$\left]
\begin{tabular}{@{}c@{}}\strut\\\strut\\\strut\\\strut\\\strut\end{tabular}\right.\kern-\nulldelimiterspace
\parbox{\dimexpr8cm-1em}{And here we have some long text,
which I want to wrap over multiple lines please. Is that possible?}$} \\
Two \\
Three \\
Four \\
Five \\
\hline
\end{tabular}
\end{document}
\raisebox{<raise>}[0pt][0pt]{<stuff>}
移除的高度/深度<stuff>
,因此将放在\parbox
第二行可以让它填充该特定行的上方/下方。
答案3
\documentclass[draft]{scrbook}
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}
\begin{document}
\noindent
\begin{tabularx}{8cm}{@{} >{$}l<{$} X @{}}\hline
\left.\begin{tabular}{@{\kern-\nulldelimiterspace} l }
One \\ Two \\ Three
\end{tabular}\right]
&
And here we have some long text, which I want to wrap over multiple
lines please. Is that possible? \\\hline
\end{tabularx}
\noindent
\begin{tabularx}{8cm}{@{} >{$}l<{$} X @{}}\hline
\left.\begin{tabular}{@{\kern-\nulldelimiterspace} l }
One \\ Two \\ Three \\ Four
\end{tabular}\right]
&
And here we have some long text, which I want to wrap over multiple
lines please. Is that possible? \\\hline
\end{tabularx}
\noindent
\begin{tabularx}{8cm}{@{} >{$}l<{$} X @{}}\hline
\left.\begin{tabular}{@{\kern-\nulldelimiterspace} l }
One \\ Two
\end{tabular}\right]
&
And here we have some long text, which I want to wrap over multiple
lines please. Is that possible? \\\hline
\end{tabularx}
\end{document}