
Ich habe die folgende Tabelle und möchte, dass sie 1
zentriert in der linken Spalte angezeigt wird.
\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}
Antwort1
Ich habe zu Davids Lösung (in einem Kommentar zu Ihrer Frage) die Breite hinzugefügt, \myw
um eine Spalte mit der exakten Breite der Zeichenfolge zu erhalten 1
. Wenn Sie auch Zahlen mit 2 oder 3 Ziffern haben, ändern Sie diese einfach \settowidth{\myw}{...}
oder geben Sie innerhalb der Spaltendefinition eine beliebige Breite ein 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}