表格单元格对齐

表格单元格对齐

我觉得这是一个菜鸟问题,但我一直在努力寻找答案。

我正在尝试创建一个包含两个并排段落的表格。使用常规表格时,它们不会并排显示。如果我使用,可以解决这个问题\parbox,但有时我希望能够\mdframed在一侧使用。

我如何让这两个单元格对齐?

\documentclass{article}
\usepackage{array}
\usepackage{mdframed}

\begin{document}
\begin{tabular}{p{.4\textwidth} | p{.58\textwidth}}


Hello from the other side.\\
I must have called 100 times.\\


&


To tell you I'm sorry for everything that I've done
But when I call you never seem to be home
Hello from the outside
At least I can say that I've tried
To tell you I'm sorry for breaking your heart
But it don't matter. It clearly doesn't tear you apart anymore.
\end{tabular}


\begin{tabular}{l | l}


\parbox[t][][t]{.4\textwidth}{Hello from the other side.\\
I must have called 100 times.\\
}

&

\parbox[t][][t]{.58\textwidth}{
To tell you I'm sorry for everything that I've done
But when I call you never seem to be home
Hello from the outside
At least I can say that I've tried
To tell you I'm sorry for breaking your heart
But it don't matter. It clearly doesn't tear you apart anymore.
}

\end{tabular}


\begin{tabular}{l | l}


\parbox[t][][t]{.4\textwidth}{Hello from the other side.\\
I must have called 100 times.\\
}

&

\parbox[t][][t]{.58\textwidth}{
\begin{mdframed}[linecolor=blue]
To tell you I'm sorry for everything that I've done
But when I call you never seem to be home
Hello from the outside
At least I can say that I've tried
To tell you I'm sorry for breaking your heart
But it don't matter. It clearly doesn't tear you apart anymore.
\end{mdframed}
}

\end{tabular}

\end{document}

在此处输入图片描述

谢谢。

答案1

您的大多数问题都在评论中得到解答(见约翰内斯·B萨利姆布),mdframed您可能希望文本对齐。这只有在您也在左侧使用 mdframed 但带有白线(白纸上不可见)的情况下才有可能:

在此处输入图片描述

\documentclass{article}
\usepackage{array}
\usepackage{mdframed}

    \begin{document}
\begin{tabular}{p{.4\textwidth} | p{.58\textwidth}}
Hello from the other side.\newline
I must have called 100 times.
    &   To tell you I'm sorry for everything that I've done
        But when I call you never seem to be home
        Hello from the outside
        At least I can say that I've tried
        To tell you I'm sorry for breaking your heart
        But it don't matter. It clearly doesn't tear you apart anymore.
    \end{tabular}

\begin{tabular}{p{.4\textwidth} | p{.58\textwidth}}
\begin{mdframed}[linecolor=white]
Hello from the other side.\newline
I must have called 100 times.
\end{mdframed}
    &   \begin{mdframed}[linecolor=blue]
        To tell you I'm sorry for everything that I've done
        But when I call you never seem to be home
        Hello from the outside
        At least I can say that I've tried
        To tell you I'm sorry for breaking your heart
        But it don't matter. It clearly doesn't tear you apart anymore.
        \end{mdframed}
\end{tabular}
    \end{document}

为了减少环境前后的垂直空间mdframed,您需要相应地重新定义参数。

相关内容