我有下表,我想让它1
出现在左列的中央。
\documentclass{article}
\begin{document}
\begin{tabular}{|l|p{1in}|}
\hline
1 & a b c d e f g h i j k l m n o p q r s t u v w x y z \\
\hline
\end{tabular}
\end{document}
答案1
我已经在 David 的解决方案(在对您的问题的评论中)中添加了宽度,\myw
以使列的宽度与字符串的宽度完全相同1
,如果您还有 2 位或 3 位数字,只需\settowidth{\myw}{...}
在列定义中更改或放置您喜欢的任何宽度即可m{...}
。
\documentclass{article}
\usepackage{array}
\newlength{\myw}
\settowidth{\myw}{1}
\begin{document}
\noindent\emph{David's solution (with \textbackslash\texttt{array} package)}
Note that both colums must have \texttt{m\{\dots\}} type.
\begin{center}
\begin{tabular}{|m{\myw}|m{1in}|}
\hline
1 & a b c d e f g h i j k l m n o p q r s t u v w x y z \\
\hline
\end{tabular}
\end{center}
\noindent\emph{Steven's solution (with no extra packages)}
Note that it's necessary to explicity give the height of the \arraybackslash\texttt{parbox}.
Otherwise, the lines overlap the text.
\begin{center}
\begin{tabular}{|l|p{1in}|}
\hline
1 & \parbox[c][1.2\height]{1in}{a b c d e f g h i j k l m n o p q r s t u v w x y z}\\
\hline
\end{tabular}
\end{center}
\end{document}