\documentclass{article}
\usepackage{tabularx}
\begin{document}
\newcolumntype{L}[1]{>{\hsize=#1\hsize\raggedright\small\arraybackslash}X}%
\begin{tabularx}{\textwidth}{ c | L{1.3} | L{1.2} L{1.2} | L{.65} L{.65} }
Mechanism\newline\ State
& Initialization\newline\ feh
& xAV
& yAV
& Hard reset (jumper)
& Hard reset (swap) \\
\begin{minipage}[t]{20pt}
Mechanism\\ State
\end{minipage}
& Initialization
& xAV
& yAV
& Hard reset (jumper)
& Hard reset (swap)
\end{tabularx}
\end{document}
版本:
Running `LaTeX' on `z1' with ``xelatex -file-line-error -interaction=nonstopmode "\input" z1.tex''
This is XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017/MacPorts 2017_1) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
LaTeX2e <2017-04-15>
...
答案1
\newline
仅适用于段落模式单元格,不适用于标准l,c,r
。但对于这些单元格,您可以使用makecell
包,它允许换行和通用格式。默认情况下,\makecell
或\thead
命令的内容在水平和垂直方向上居中:
\documentclass{article}
\usepackage{tabularx, makecell}
\newcolumntype{L}[1]{>{\hsize=#1\hsize\raggedright\small\arraybackslash}X}%
\renewcommand{\theadfont}{\small\bfseries}
\begin{document}
\begin{tabularx}{\textwidth}{ c | L{1.3} | L{1.2} L{1.2} | L{.65} L{.65} }
\thead[tc]{Mechanism\\ State}
& Initialization\break\ feh
& xAV
& yAV
& Hard reset (jumper)
& Hard reset (swap) \\
\makecell{Mechanism\\ State}
& Initialization
& xAV
& yAV
& Hard reset (jumper)
& Hard reset (swap)
\end{tabularx}
\end{document}