我想加载makecell
带有默认选项的包,使所有\makecell
单元格默认左对齐。我应该在下面替换什么OPTIONS
才能使左对齐成为单元格的默认行为\makecell
?
\documentclass{report}
\usepackage[OPTIONS]{makecell}
\begin{document}
\begin{tabular}{cc}
\makecell{Label \\ 1} & 1234 \\
\makecell{Label \\ 2} & 5678
\end{tabular}
\end{document}
我几乎可以肯定我以前见过这种做法,但玩了一会之后我还是搞不懂,也没有在文档。
答案1
据我所知,makecell
没有提供更改默认对齐方式的选项\makecell
,但您可以使用\renewcommand\cellalign{<alignment here>}
它来全局更改默认对齐方式以满足您的喜好。
\documentclass{report}
\usepackage{makecell}
\renewcommand\cellalign{cl}
\begin{document}
\begin{tabular}{cc}
\makecell{Label \\ 1} & 1234 \\
\makecell{Label \\ 2} & 5678
\end{tabular}
\end{document}
答案2
直接从 makecell 手册中,您可以在选项中使用 t/b/c 或 r/l/c/p
\documentclass{report}
\usepackage{tabu, booktabs}
\usepackage[]{makecell}
\begin{document}
\begin{tabular}{cc}
\makecell[l]{Label \\ 1} & 1234 \\
\makecell[tl]{Label \\ 2} & 5678\\
\makecell[br]{Label \\ 3} & ABCDE
\end{tabular}
\begin{tabu} to \textwidth {lXX}
\toprule
Head Col 1 & Head Col 2 & Head Col 3 \\
\hline
Data Col 1 & Data Col 2 & \makecell[l]{here is \\ my text \\ in the cell} \\
\addlinespace
Data Col 1 & Data Col 2 & \makecell[tl]{here is \\ my text \\ in the cell} \\
\addlinespace
Data Col 1 & Data Col 2 & \makecell[br]{here is \\ my text \\ in the cell} \\
\bottomrule
\end{tabu}
\end{document}