Как выровнять следующую ячейку таблицы по центру?

Как выровнять следующую ячейку таблицы по центру?

У меня есть следующая таблица, и я хочу, 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

Я добавил к решению Дэвида (в комментарии к вашему вопросу) ширину, \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}

введите описание изображения здесь

Связанный контент