我对同一文件有如下问题: 使用 tabularx 和 linebreak 居中单元格 使用该代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage[]{multirow}
\usepackage[]{MnSymbol}
\usepackage[]{array}
\usepackage{multicol}
\begin{document}
\maketitle
\section{Introduction}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{table}
\centering
\begin{tabularx}{1\linewidth}{lX|P{0.2\linewidth}|P{0.2\linewidth}|P{0.2\linewidth}}
& & \textbf{firmware} & \textbf{bootloader} & \textbf{os} \\
\multicolumn{2}{l}{\textbf{Target1}} & & & \\
& {\footnotesize rot\par} & test123 \newline hallo & {\footnotesize $(\uparrow)$ \newline testtext\par} & {\footnotesize $(\nearrow)$ \newline hardware\par} \\
\hline
\hline
\end{tabularx}
\end{table}
\end{document}
有没有办法将第一个单元格与其他单元格中间对齐?无论单元格中有两条、三条、一条还是四条线?
答案1
类似下面这样的东西吗?
\documentclass{article}
\usepackage{array}
\usepackage{tabularx}
% \usepackage{multirow}
\usepackage{makecell}
\usepackage{MnSymbol}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\begin{document}
\section{Introduction}
\begin{table}
\renewcommand\theadfont{\normalsize\bfseries}%
\setlength\tabcolsep{3pt}
\centering%
\footnotesize%
\begin{tabularx}{\linewidth}{
C|
P{0.2\linewidth}|
P{0.2\linewidth}|
P{0.2\linewidth}
}
\thead{Target1}
& \thead{firmware}
& \thead{bootloader}
& \thead{os} \\
rot
& \makecell[cc]{$(\uparrow)$ test123\\hallo}
& $(\uparrow)$ testtext
& $(\nearrow)$ hardware \\
\hline\hline
\end{tabularx}
\end{table}
\end{document}