2

I have a table and you could (maybe) see that I want Belgium in a newline, but inside the same row as with Australia (Same at Poland and Italy).

\begin{table}[]
\begin{tabular}{|l|r|}
\hline
Country   & Counted \\ \hline
Australia  and \newline  Belgium & 690     \\ \hline
Germany   & 1000    \\ \hline
Poland and \newline Italy   & 240     \\ \hline
India     & 5397    \\ \hline
\end{tabular}
\end{table}

I am not looking for a solotion where I change the

\begin{tabular}{|l|r|}

to something like

\begin{tabular}{| p{3cm}|r|}

I could do it like:

Australia   &     \\ 
Belgium     & 690    \\ \hline

But are there better looking or more efficient sollutions for this?

1 Answers1

2

With help of the makecell package:

\documentclass{article}
\usepackage{makecell}

\begin{document}
    \begin{table}[]
\begin{tabular}{|l|r|}
\hline
Country                                 & Counted \\ \hline
\makecell[l]{Australia  and\\  Belgium} & 690     \\ \hline
Germany                                 & 1000    \\ \hline
\makecell[l]{Poland and\\ Italy}        & 240     \\ \hline
India                                   & 5397    \\ \hline
\end{tabular}
    \end{table}
\end{document}

enter image description here

or with use m column type:

\documentclass{article}
\usepackage{array}
\newlength\colwidth

\begin{document}
    \begin{table}[ht]
    \settowidth\colwidth{Australia  and}
\begin{tabular}{|m{\colwidth}|r|}
\hline
Country                 & Counted \\ \hline
Australia  and Belgium  & 690     \\ \hline
Germany                 & 1000    \\ \hline
Poland and Italy        & 240     \\ \hline
India                   & 5397    \\ \hline
\end{tabular}
    \end{table}
\end{document}

Result is the same as before.

Zarko
  • 296,517