多列中的垂直对齐

多列中的垂直对齐

在下面的代码中,右侧的水平线并非在所有情况下都与左侧的水平线对齐。这似乎与文本内容有关。我该如何解决这个问题,让它无论文本是什么都能正常工作。谢谢。

\documentclass{article}
\usepackage[top=1in,bottom=1in,left=0.5in,textwidth=7.5in]{geometry}
\usepackage{multicol}
\usepackage{tabu}
\usepackage{xcolor}
\begin{document}

\setlength{\columnseprule}{.4pt} 
\renewcommand\columnseprulecolor{\color{blue}}
\begin{multicols}{2}
\tabulinesep=4pt\begin{tabu} to \columnwidth{>{\bfseries}lX} 
\everyrow{\tabucline[blue]-}
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
\end{tabu} 
\tabulinesep=4pt\begin{tabu} to \columnwidth{>{\bfseries}lX} 
\everyrow{\tabucline[blue]-}
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & more / words \\ 
Some words & and some more \\ 
\end{tabu} 
\end{multicols} 
\end{document}

输出如下所示:

截屏

添加:

David Carlisle 提出了多行内容的问题,所以我使用他的代码尝试了这一点。请注意,它没有对齐。可能在这种情况下,如果有多行内容,就无法以一般方式对齐,但如果可能的话,知道如何做到这一点会很有趣。

\documentclass{article}
\usepackage[top=1in,bottom=1in,left=0.5in,textwidth=7.5in]{geometry}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{tabu}
\usepackage{xcolor}
\begin{document}

\setlength{\columnseprule}{.4pt} 
\renewcommand\columnseprulecolor{\color{blue}}
\begin{multicols}{2}
\tabulinesep=4pt
\noindent
\begin{tabu} to \columnwidth{>{\bfseries}l>{\strut\ignorespaces}X<{\ifhmode\unskip\strut}} 
\everyrow{\tabucline[blue]-}
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
\end{tabu} 
\tabulinesep=4pt
\noindent
\begin{tabu} to \columnwidth{>{\bfseries}l>{\strut\ignorespaces}X<{\ifhmode\unskip\strut}} 
\everyrow{\tabucline[blue]-}
Some words & and some more \\ 
Some words &  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu- lum ut, placerat ac, adipiscing vitae, felis. \\
Some words & and some more \\ 
Some words & more / words \\ 
Some words & and some more \\ 
\end{tabu} 
\end{multicols} 
\end{document}

结果是:

截屏

答案1

您需要确保第一行和最后一行的文本至少与支柱一样高/深。您还需要\noindent在表格之前这样做,否则您会尝试将全宽表格和段落缩进挤在同一行上,每次都会超出 15pt。

\documentclass{article}
\usepackage[top=1in,bottom=1in,left=0.5in,textwidth=7.5in]{geometry}
\usepackage{multicol}
\usepackage{tabu}
\usepackage{xcolor}
\begin{document}

\setlength{\columnseprule}{.4pt} 
\renewcommand\columnseprulecolor{\color{blue}}
\begin{multicols}{2}
\tabulinesep=4pt
\noindent
\begin{tabu} to \columnwidth{>{\bfseries}l>{\strut\ignorespaces}X<{\ifhmode\unskip\strut\fi}} 
\everyrow{\tabucline[blue]-}
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
\end{tabu} 
\tabulinesep=4pt
\noindent
\begin{tabu} to \columnwidth{>{\bfseries}l>{\strut\ignorespaces}X<{\ifhmode\unskip\strut\fi}} 
\everyrow{\tabucline[blue]-}
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & more / words \\ 
Some words & and some more \\ 
\end{tabu} 
\end{multicols} 
\end{document}

相关内容