\raggedright 列产生“\midrule ->\noalign”

\raggedright 列产生“\midrule ->\noalign”

我正在尝试使用 格式化“段落”表格列\raggedright。但是,它生成错误“\midrule ->\noalign”。感谢您的帮助:

% Test.tex
%--------------
\documentclass{article}
\usepackage{calc}
\usepackage{array}
\usepackage{booktabs}
%\usepackage[document]{ragged2e} % Has no effect
\begin{document}

% This works:
\begin{tabular}{>{\centering}p{\widthof{Symbolic}}lp{3.5in}}

% This yields error "\midrule ->\noalign":
%\begin{tabular}{>{\centering}p{\widthof{Symbolic}}l>{\raggedright}p{3.5in}}

\toprule
   Symbolic algebra & Code variable & Explanation \\
\midrule
   $x_i$ & ifPrj(i) &
   The quick brown fox jumped over the lazy dogs.
   The quick brown fox jumped over the lazy dogs.
   The quick brown fox jumped over the lazy dogs.
   The quick brown fox jumped over the lazy dogs.
\\
\bottomrule

\end{tabular}

\end{document}

页面被引用来回答这个问题,但我发现关于如何使用对齐命令的信息要广泛得多。我的问题在这里非常集中于一个特定的错误。人们可能会根据特定的错误进行搜索。

答案1

\\我觉得自己是个……极其不聪明的人。通过将全部替换为以下内容可解决该问题\tabularnewline

\documentclass{article}
\usepackage{calc}
\usepackage{array}
\usepackage{booktabs}
\begin{document}

\begin{tabular}{>{\centering}p{\widthof{Symbolic}}l>{\raggedright}p{3.5in}}

\toprule
   Symbolic algebra & Code variable & Explanation \tabularnewline
\midrule
   $x_i$ & ifPrj(i) &
   The quick brown fox jumped over the lazy dogs.
   The quick brown fox jumped over the lazy dogs.
   The quick brown fox jumped over the lazy dogs.
   The quick brown fox jumped over the lazy dogs.
\tabularnewline
\bottomrule

\end{tabular}

\end{document}

根据 egreg 的评论,我找到了更完整的问题描述和解决方案这里。必须搜索短语“问题在于 \raggedright 重新定义了 \\”。

相关内容