2

I'm trying to make a table with a column of a certain width. Using basic {tabular} and the p parameter creates column of the given width plus some extra millimeters (for example p{50mm} leads to width of about 55 mm when printed). When I try {tabularx} and add a specific width for the whole table, it works just fine, without any added width on print (so I guess the problem probably isn’t in printer settings).

\documentclass{article}
\usepackage[czech]{babel}
\usepackage[utf8]{inputenc}

\begin{document}
    \begin{tabular}{|p{50mm}|c|c|c|c|}
        \hline
        1&2&3&4&5\\
        \hline
        1&2&3&4&5\\
        \hline
        1&2&3&4&5\\
        \hline
    \end{tabular}
\end{document}

Thanks.

1

You have to subtract the column separator from your length.

column separator

\documentclass{article}
\usepackage[czech]{babel}
\usepackage[utf8]{inputenc}

\begin{document}
    \begin{tabular}{|p{\dimexpr 50mm-2\tabcolsep}|c|c|c|c|}
        \hline
        1&2&3&4&5\\
        \hline
        1&2&3&4&5\\
        \hline
        1&2&3&4&5\\
        \hline
    \end{tabular}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.