有没有简单的方法可以让包含“Q(2)”的单元格垂直居中?
\documentclass[12pt,paper=a4,addpoints,cancelspace]{exam}
\usepackage{array}
\usepackage{censor}
\censorruledepth=-.2ex
\censorruleheight=.1ex
\begin{document}
\noindent
\begin{table}[h]
\begin{center}
\scriptsize
\label{1}
\scriptsize
\renewcommand{\arraystretch}{1.4}
\begin{tabular}{|p{0.7\textwidth}|
>{\centering\arraybackslash}wc{0.1\textwidth}|
>{\centering\arraybackslash}wc{0.1\textwidth}|
}
\hline
Title &Something &Something \\ \hline
\hline
2. Apply the concepts of basic vector spaces topics to Rn and to the solution spaces of the ordinary
differential equations. & Q (2) & \\ \hline
\hline
\end{tabular}
\end{center}
\vspace{-0.5em}
\end{table}
\end{document}
答案1
由于您加载了包,您可以通过将列类型替换为列 1 的列类型来array
实现格式化目标。p
m
无论您选择做什么,请用 替换>{\centering\arraybackslash}wc{0.1\textwidth}
。w{c}{0.1\textwidth}
换句话说,请删除>{\centering\arraybackslash}
“前缀”之类的东西。
\documentclass[12pt,paper=a4,addpoints,cancelspace]{exam}
\usepackage{array,amssymb}
\usepackage{censor}
\censorruledepth=-.2ex
\censorruleheight=.1ex
\begin{document}
%\noindentn% redundant
\begin{table}[h]
\centering % use "\centering" rather than a "center" environment
\scriptsize
%\label{1} "\label" doesn't have desired effect unless preceded by "\caption"
\renewcommand{\arraystretch}{1.4}
\begin{tabular}{|m{0.7\textwidth}| % <-- use 'm', not 'p', col. type
w{c}{0.1\textwidth}|
w{c}{0.1\textwidth}|
}
\hline
Title & Something & Something \\
\hline\hline
2. Apply the concepts of basic vector spaces topics
to $\mathbb{R}^n$ and to the solution spaces of
the ordinary differential equations. &
Q (2) & \\
\hline\hline
\end{tabular}
\end{table}
\end{document}
附录m
: 除了使用显式列类型而不是列类型之外,实现所需垂直居中的另一种方法p
是使用tabularx
环境并运行指令\renewcommand\tabularxcolumn[1]{m{#1}}
。这是因为包X
定义的列类型tabularx
是是p
带有“扭曲”的列——事实上 LaTeX 会自动计算其宽度作为残差。
对于下面的截图,我去掉了指令\scriptsize
(主要是因为我不明白它的用途),并用 替换了两个w{c}{0.1\textwidth}
。c
上面的tabularx
环境继续使用大量垂直和水平规则来呈现巴洛克风格;下面的tabularx
环境通过去掉所有垂直规则并使用更少但间距适当的水平规则来消除许多不必要的东西。
\documentclass[12pt,paper=a4,addpoints,cancelspace]{exam}
\usepackage{array,amssymb}
\usepackage{censor}
\censorruledepth=-.2ex
\censorruleheight=.1ex
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}} % for vertical centering
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{booktabs} % for well-spaced horizontal rules
\begin{document}
\begin{table}[h]
%\renewcommand{\arraystretch}{1.4}
\setlength\extrarowheight{2pt}
\begin{tabularx}{\textwidth}{|L|c|c|}
\hline
Title & Something & Something \\
\hline\hline
2. Apply the concepts of basic vector spaces topics
to $\mathbb{R}^n$ and to the solution spaces of
the ordinary differential equations.
& Q (2) & \\
\hline\hline
\end{tabularx}
\vspace{1cm}
% same structure, but without any vertical rules, and with fewer, but well-spaced, horizontal rules
\begin{tabularx}{\textwidth}{@{} Lcc @{}}
\toprule
Title & Something & Something \\
\midrule
2. Apply the concepts of basic vector spaces topics
to $\mathbb{R}^n$ and to the solution spaces of
the ordinary differential equations.
& Q (2) & \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}