3

I'm working with

\begin{tabular}{lll}
\textbf{text} & \textbf{text} & \textbf{text}\\
&&\\
.
.
.
&&\\
\end{tabular}

Since lll puts everything at the left. What's the way to center the words of the first line of the table and the rest lines have the lll align?


I'm using

\begin{tabular}{lll}
\multicolumn{3}{c}\textbf{text} & \textbf{text} &\textbf{text}\\
&&\\
&&\\
\end{tabular}

But it's nor working.

  • 4
    \multicolumn{3}{c}{your text} \\ – user31729 Nov 25 '15 at 17:45
  • 2
    If you want to center each of the 3 Texts, then you can do Christians approach just with {1} in every cell, see also tex.stackexchange.com/questions/33486/… – Ronny Nov 25 '15 at 17:50
  • I tried \multicolumn{3}{c}{your text} but it gave me an error. Also I tried putting {1} on each cell but it gave me a bad result. – Alejandro Nov 25 '15 at 17:56
  • 2
    Use \hfil\textbf{text} instead \textbf{text}. – wipet Nov 25 '15 at 17:56
  • See my edited answer please. – Alejandro Nov 25 '15 at 17:59
5

I was pretty sure that this is a duplicate question, but any other question I found was way more complicated. In any case, the correct way to use \multicolumn is:

\begin{tabular}{lll}
\multicolumn{1}{c}{\textbf{text}} & \multicolumn{1}{c}{\textbf{text}} &\multicolumn{1}{c}{\textbf{text}}\\
a&b&c\\
12346543432&1253156&lalala\\
\end{tabular}

the final table

Note:

  1. The first argument tells how many cells you want to combine together. Here, you just want to change a single cell by itself and not combine it with any neighbouring cell.
  2. The second argument specifies the format of the cell (here: 'c'entered).
  3. The third argument (!) is the contents of the cell. Thus, the contents of the cell as to be between { and }.
3

The thead command, from makecell, allows for a common formatting of its argument, line breaks and is by default vertically and horizontally centred.

Demo of usage:

\documentclass{article}
\usepackage{array, makecell}
\renewcommand\theadfont{\bfseries}

\begin{document}

\begin{tabular}{lll}
  \thead{text1\\text2} & \thead{text} &\thead{text}\\
  Blah blah & Blah blah & Blah blah \\
  Blah & Blah & Blah \\
\end{tabular}

\end{document} 

enter image description here

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.