
我想在表格環境中的旋轉框中新增一行。 MWE如下:
\documentclass[english]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{lmodern}
\usepackage{graphicx}
\begin{document}
\begin{tabular}{p{5cm} | p{5cm}}
A & B \\
Here it \newline works & \rotatebox{90}{Here it \newline doesn‘t} \\
\end{tabular}
\end{document}
先致謝!
答案1
第二個參數的內容\rotatebox
受到一些有關可能內容的限制性假設的約束。這就是為什麼您在查詢中嘗試的方法不太“有效”的原因。
一個靈活的解決方案是定義一個自訂tabular
環境並將其用於 的第二個參數\rotatebox
。這是在以下範例中完成的。
\documentclass[english]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype,array,lmodern,graphicx}
\newcommand\mytab[1]{\begin{tabular}[t]{c}#1\end{tabular}}
\newcommand\rotbox[1]{\rotatebox[origin=c]{90}{\mytab{#1}}}
\begin{document}
\begin{tabular}{|p{5cm}|>{\centering\arraybackslash}p{5cm}|}
\hline
A & B \\
\hline
Here it \newline works & \rotbox{Here it\\does too} \\
\hline
\end{tabular}
\end{document}