I want a table where the cells contain either a single line of text or two lines of text, and the cell contents are both horizontally and vertically centered.

The height of the cells should be 2cms and length 3cms (assuming the text does not overflows), and some of the cell boundaries should be bold.

One example is as follows:

enter image description here

Any help to create such a table in latex would be much appreciated. Thank You.

  • 1
    search for \mbox – Surb Sep 21 '19 at 11:58
  • 1
    @Surb I can't think of any way \mbox would help with this question – David Carlisle Sep 21 '19 at 12:10

Here are two ways, depending on whether you have fixed width cells or not:

  • for a standard cell (column specifier r, l or c), you can use the makecell command,
  • for a fixed width cell, use the m{some length} column type

A demo of both:




    \begin{tabular}{ | c | c !{\vrule width2.5pt}}
\makecell{multi-lined \\ contents} & single line \\
    \begin{tabular}{|>{\centering}m{20mm}|>{\centering\arraybackslash}m{20mm} !{\vrule width2.5pt}}
 multi-lined \newline contents & single line \\

enter image description here

| improve this answer | |
  • Thank you for your answer. I am wondering if the space between the two lines 'multi-lined' and 'contents' can be reduced? Also, if I increase the height of the cell for the first option, like \renewcommand\cellgape{\Gape[10pt]}, both the lines move far apart, can this be reduced? And in the second option, if I increase the height by \setlength{\extrarowheight}{20pt} the lines are placed towards the bottom of the cell instead of the center. – user197878 Sep 21 '19 at 13:02
  • Actuallt \cellgape adds this amount of vertical space at the top and bottom of cells, so this is the normal behaviour . Another solution, valid for both methods, use the cellspace package which ensures a minimal vertical spacing at top and bottom of cells in columns with specifier prefixed with the letter S (or C if you also load siunitx). For instance, here, you might use as tables preambles {|Sc|Sc!{\vrule width 2.5pt} and {|>{\centering}S{m{20mm}}|>{\centering\arraybackslash}S{m{20mm} }!{\vrule width2.5pt}} respectively. – Bernard Sep 21 '19 at 13:34

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.