1

I have the following table, and I want the 1 to appear centered in the left column.

\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}
5
  • 1
    change l to c in the tabular argument (or do you mean vertical center, in which case change to m and add \usepackage{array}) Commented Apr 28, 2017 at 16:16
  • @DavidCarlisle I think he/she is talking vertical centering... Commented Apr 28, 2017 at 16:17
  • Cumbersome, but, 1 & \parbox[c]{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} Commented Apr 28, 2017 at 16:19
  • @DavidCarlisle only if you also include the array or tabularx package... Commented Apr 28, 2017 at 16:20
  • @DavidCarlisle You edited your comment without me noticing... two can play at that game. Commented Apr 28, 2017 at 16:23

1 Answer 1

1

I have added to David's solution (in a comment to your question) the width \myw to have a column of the exact width of the string 1, if you also have numbers of 2 or 3 digits just change \settowidth{\myw}{...} or put any width you like within the column definition 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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .