無法在兩列(或多列)翻譯表格中居中或「輸入」(在右列)

無法在兩列(或多列)翻譯表格中居中或「輸入」(在右列)

這篇文章是我舊文的後續:在表格內或並行包內繪製垂直線(以及如何擴展並行以擁有超過 2 列

不過,似乎還是不可能擁有

  • 右列居中文本
  • 右列中同一「條目」內的多個文字行

這些問題用下面的程式碼表示:

\documentclass{article}

\newlength\svparskip
\newlength\delfix
\delfix1.3pt
\newlength\colwidth
\setlength\colwidth{\dimexpr.5\textwidth-2\tabcolsep}
\newlength\splitcolwidth
\setlength\splitcolwidth{\dimexpr.25\textwidth-2\tabcolsep}
\newenvironment{partabular}
  {\par\svparskip=\parskip\relax\vspace{\delfix}}
  {\vspace{\delfix}\parskip=\svparskip\relax}
\newenvironment{nextentry}
  {\parskip-\delfix\par\noindent\begin{tabular*}{\textwidth}[t]
  {|p{\colwidth}|p{\colwidth}|}\hline}{\hline\end{tabular*}\par}
\def\filllines#1{\vspace{\dimexpr#1\ht\strutbox+#1\dp\strutbox}}

\begin{document}

\begin{partabular}
\begin{nextentry}
\centering{\textbf{$(A)$ some text i can center}} & {\centering{\textbf{$(B)$ some text i can't center}}} \\\hline
$(C)$ some text here and then enter \\ and have some more text below \\ which is possible & $(D)$ \textbf{some text here but then enter} \\ \textbf{and have some more text below} \\ \textbf{isn't possible + the vertical lines on the right get distorted ...} \\
\end{nextentry}
\begin{nextentry}
$(E)$ & $(F)$ \\\hline
\begin{tabular}[t]{@{}p{\splitcolwidth}|p{\splitcolwidth}@{}}
$(H)_1$ \filllines{6}& $(H)_2$
  \end{tabular} 
& \vspace{1cm} Thanks for any help in advance! :) \\
\end{nextentry}
\end{partabular}

\end{document}

答案1

由於您手動擴展一列中的垂直方向,因此我不確定如何在另一列中自動化該過程。但如果您可以忍受手動幹預,您應該能夠透過\filllines{}手動插入空白行來實現您想要的垂直佈局。

編輯以實現單元格 B、D、F 和右下單元格的水平居中。為了\centering生效,\par必須生效。這可以在最後兩種情況下完成{\centering...\par},但由於單元格“B”和“F”是一行,我必須用 來實現\hfil...\hfill,以免\par產生不需要的空白行。

為了回答OP關於我如何垂直居中單元格“D”的評論,關鍵是使單元格“C”成為單一單元格,而OP的MWE將單元格“C”組成兩個獨特的單元格。

\documentclass{article}
\newlength\svparskip
\newlength\delfix
\delfix1.3pt
\newlength\colwidth
\setlength\colwidth{\dimexpr.5\textwidth-2\tabcolsep}
\newlength\splitcolwidth
\setlength\splitcolwidth{\dimexpr.25\textwidth-2\tabcolsep}
\newenvironment{partabular}
  {\par\svparskip=\parskip\relax\vspace{\delfix}}
  {\vspace{\delfix}\parskip=\svparskip\relax}
\newenvironment{nextentry}
  {\parskip-\delfix\par\noindent\begin{tabular*}{\textwidth}[t]
  {|p{\colwidth}|p{\colwidth}|}\hline}{\hline\end{tabular*}\par}
\def\filllines#1{\vspace{\dimexpr#1\ht\strutbox+#1\dp\strutbox}}

\begin{document}

\begin{partabular}
\begin{nextentry}
\centering{\textbf{$(A)$ some text i can center}} 
  & \hfil\bfseries$(B)$ some text i can't center\hfill\\ \hline
$(C)$ some text here and then enter and have some more text below  which is possible\bfseries\par\bigskip
and have some more text below
isn't possible + the vertical lines on the right get distorted ...
&  \filllines{2.5}{\centering$(D)$ \bfseries text here but then enter\par}
\filllines{2} \\ 
\end{nextentry}
\begin{nextentry}
$(E)$ & \hfil$(F)$\hfill \\\hline
\begin{tabular}[t]{@{}p{\splitcolwidth}|p{\splitcolwidth}@{}}
$(H)_1$ \filllines{6}& $(H)_2$
  \end{tabular} 
& \filllines{2.5} {\centering Thanks for any help in advance! :)\par} \\
\end{nextentry}
\end{partabular}
\end{document}

在此輸入影像描述

相關內容