2

I'm trying to have two minipages side by side and each of of them has a table inside. However they are overlapping for some reason, I've done some research here but none of the solutions offered worked for me, can someone point out why aren't the tables exactly side by side? Thank you.

Here is the code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\noindent
\begin{minipage}{0.49\hsize}
\begin{tabular}{|c|c|}
1-Alex Mateus Gianetti & 99981-9517 \\
2-Alinne Freitas Signorelli & 99100-6388 \\
3-Ana Claudia Perroni & 99296-5945 \\
4-Ana Estela Delgado & 98112-3965 \\
5-Ana Paula de Siqueira Faria & 99200-9854 \\
6-Ana Paula Falcão Lima & 98132-1331 \\
7-Ana Paula Santos Fava &  \\
8-André Lacerda & 99271-0340 \\
9-André Yuri de Oliveira Borges & 99262-8895 \\
10-Andreia Mantovani & 98123-7691
\end{tabular}
\end{minipage}%
\begin{minipage}{0.49\hsize}
\begin{tabular}{|c|c|}
50-Isadora Cacho Justino & 99189-8499 \\
51-Isadora Gouveia Lara Bueno & 98435-1645 \\
52-Jeperson Pedro de Oliveira & 98152-0000 \\
53-Jéssica Melo & 99101-7979 \\
54-Joana Camargo Marchezan & 99683-5978 \\
55-João Paulo Correa da Silveira  & 99296-3438 \\
56-José Henrique Avila de Rezende & 99985-8175 \\
57-José Melo & 99951-2737 \\
58-José Rodrigues Maria & 98467-4688 \\
59-Juliane Vogel & 99241-4765 \\
60-Karina Barbosa de Alencar Oliveira & 99208-8128
\end{tabular}
\end{minipage}
\end{document}

And here is how it is coming out:

enter image description here

5
  • 2
    Welcome to TeX.SX! The tables inside the minipages are wider than the allotted space.
    – egreg
    Nov 3, 2017 at 18:19
  • Thank you! So how can I make the tables compress to fit inside the minipages? Nov 3, 2017 at 18:22
  • @AlexandreKrabbe You can use tabularx package. \begin{tabularx}{\linewidth}{|c|c|} your code \end{tabularx} Nov 3, 2017 at 18:27
  • Have a look at Resize a tabular object to textwidth.
    – Bobyandbob
    Nov 3, 2017 at 18:28
  • @MichaelFraiman - At least one of the columns in a tabularx environment should be of type X (or be based on an X column).
    – Mico
    Nov 3, 2017 at 18:47

3 Answers 3

1

Well, it depends of what you need, but I see two possibilitys here:

  1. Change c to p{3cm} or which value you need.
  2. Use package tabularx and environment tabularx instead environment tabular. With package ragged2e you get the command \RaggedRight for a better hyphenation of left justified text.

The following MWE shows both possibilitys:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{tabularx} % <===============================================
\usepackage{ragged2e} % <===============================================
\usepackage{showframe}

\begin{document}
\noindent
\begin{minipage}{0.49\hsize}
\begin{tabular}{|p{3cm}|c|}
1-Alex Mateus Gianetti & 99981-9517 \\
2-Alinne Freitas Signorelli & 99100-6388 \\
3-Ana Claudia Perroni & 99296-5945 \\
4-Ana Estela Delgado & 98112-3965 \\
5-Ana Paula de Siqueira Faria & 99200-9854 \\
6-Ana Paula Falcão Lima & 98132-1331 \\
7-Ana Paula Santos Fava &  \\
8-André Lacerda & 99271-0340 \\
9-André Yuri de Oliveira Borges & 99262-8895 \\
10-Andreia Mantovani & 98123-7691
\end{tabular}
\end{minipage}%
\hfil
\begin{minipage}{0.49\hsize}
\begin{tabular}{|p{3cm}|c|}
50-Isadora Cacho Justino & 99189-8499 \\
51-Isadora Gouveia Lara Bueno & 98435-1645 \\
52-Jeperson Pedro de Oliveira & 98152-0000 \\
53-Jéssica Melo & 99101-7979 \\
54-Joana Camargo Marchezan & 99683-5978 \\
55-João Paulo Correa da Silveira  & 99296-3438 \\
56-José Henrique Avila de Rezende & 99985-8175 \\
57-José Melo & 99951-2737 \\
58-José Rodrigues Maria & 98467-4688 \\
59-Juliane Vogel & 99241-4765 \\
60-Karina Barbosa de Alencar Oliveira & 99208-8128
\end{tabular}
\end{minipage}

Second possibility:

\noindent
\begin{minipage}{0.49\hsize}
\begin{tabularx}{\linewidth}{|>{\RaggedRight}X|c|} % <==================
1-Alex Mateus Gianetti          & 99981-9517 \\
2-Alinne Freitas Signorelli     & 99100-6388 \\
3-Ana Claudia Perroni           & 99296-5945 \\
4-Ana Estela Delgado            & 98112-3965 \\
5-Ana Paula de Siqueira Faria   & 99200-9854 \\
6-Ana Paula Falcão Lima         & 98132-1331 \\
7-Ana Paula Santos Fava         &  \\
8-André Lacerda                 & 99271-0340 \\
9-André Yuri de Oliveira Borges & 99262-8895 \\
10-Andreia Mantovani            & 98123-7691
\end{tabularx}
\end{minipage}%
\hfil
\begin{minipage}{0.49\hsize}
\begin{tabularx}{\linewidth}{|>{\RaggedRight}X|c|} % <==================
50-Isadora Cacho Justino              & 99189-8499 \\
51-Isadora Gouveia Lara Bueno         & 98435-1645 \\
52-Jeperson Pedro de Oliveira         & 98152-0000 \\
53-Jéssica Melo                       & 99101-7979 \\
54-Joana Camargo Marchezan            & 99683-5978 \\
55-João Paulo Correa da Silveira      & 99296-3438 \\
56-José Henrique Avila de Rezende     & 99985-8175 \\
57-José Melo                          & 99951-2737 \\
58-José Rodrigues Maria               & 98467-4688 \\
59-Juliane Vogel                      & 99241-4765 \\
60-Karina Barbosa de Alencar Oliveira & 99208-8128
\end{tabularx}
\end{minipage}
\end{document}

with the result:

resulting pdf

1
  • would look nicer if that first column were set \Raggedright (package ragged2e to allow hyphenation). Nov 3, 2017 at 19:23
0

The width of the left table is 213.75037pt, but 49% of the text width is just 169.0519pt, the excess goes off the right margin of the minipage.

You have two choices, equally bad: choice one is scaling the tables, but you'll get different font sizes; choice two is leaving the tables go off the page margins.

Choice three would be to reduce the font size yourself, but even with \scriptsize the two tables wouldn't fit.

Choice four: reformat the names.

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

\newcommand{\nm}[3]{%
  \begin{tabular}{@{}l@{}l@{}}
  \ifnum#1<10 \phantom{0}\fi#1\,-\,&
  #2\\&#3
  \end{tabular}%
}


\begin{document}

\begin{center}\small
\begin{tabular}{|l|c|}
\nm{1}{Alex Mateus}{Gianetti} & 99981-9517 \\
\nm{2}{Alinne Freitas}{Signorelli} & 99100-6388 \\
\nm{3}{Ana Claudia}{Perroni} & 99296-5945 \\
\nm{4}{Ana Estela}{Delgado} & 98112-3965 \\
\nm{5}{Ana Paula}{de Siqueira Faria} & 99200-9854 \\
\nm{6}{Ana Paula}{Falcão Lima} & 98132-1331 \\
\nm{7}{Ana Paula}{Santos Fava} &  \\
\nm{8}{André}{Lacerda} & 99271-0340 \\
\nm{9}{André Yuri}{de Oliveira Borges} & 99262-8895 \\
\nm{10}{Andreia}{Mantovani} & 98123-7691
\end{tabular}\hfill
\begin{tabular}{|l|c|}
\nm{50}{Isadora}{Cacho Justino} & 99189-8499 \\
\nm{51}{Isadora Gouveia}{Lara Bueno} & 98435-1645 \\
\nm{52}{Jeperson Pedro}{de Oliveira} & 98152-0000 \\
\nm{53}{Jéssica}{Melo} & 99101-7979 \\
\nm{54}{Joana}{Camargo Marchezan} & 99683-5978 \\
\nm{55}{João Paulo}{Correa da Silveira } & 99296-3438 \\
\nm{56}{José Henrique}{Avila de Rezende} & 99985-8175 \\
\nm{57}{José}{Melo} & 99951-2737 \\
\nm{58}{José}{Rodrigues Maria} & 98467-4688 \\
\nm{59}{Juliane}{Vogel} & 99241-4765 \\
\nm{60}{Karina Barbosa}{de Alencar Oliveira} & 99208-8128
\end{tabular}
\end{center}

\end{document}

enter image description here

With scaling:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}

\usepackage{lipsum}

\begin{document}

\lipsum[3]

\begin{center}
\resizebox{\textwidth}{!}{%
\begin{tabular}{|c|c|}
1-Alex Mateus Gianetti & 99981-9517 \\
2-Alinne Freitas Signorelli & 99100-6388 \\
3-Ana Claudia Perroni & 99296-5945 \\
4-Ana Estela Delgado & 98112-3965 \\
5-Ana Paula de Siqueira Faria & 99200-9854 \\
6-Ana Paula Falcão Lima & 98132-1331 \\
7-Ana Paula Santos Fava &  \\
8-André Lacerda & 99271-0340 \\
9-André Yuri de Oliveira Borges & 99262-8895 \\
10-Andreia Mantovani & 98123-7691
\end{tabular}%
\begin{tabular}{|c|c|}
50-Isadora Cacho Justino & 99189-8499 \\
51-Isadora Gouveia Lara Bueno & 98435-1645 \\
52-Jeperson Pedro de Oliveira & 98152-0000 \\
53-Jéssica Melo & 99101-7979 \\
54-Joana Camargo Marchezan & 99683-5978 \\
55-João Paulo Correa da Silveira  & 99296-3438 \\
56-José Henrique Avila de Rezende & 99985-8175 \\
57-José Melo & 99951-2737 \\
58-José Rodrigues Maria & 98467-4688 \\
59-Juliane Vogel & 99241-4765 \\
60-Karina Barbosa de Alencar Oliveira & 99208-8128
\end{tabular}}
\end{center}

\end{document}

enter image description here

0

You have two main choices:

  • If you do not want to allow linebreaks in columns 1 and 3, you need to switch to a tiny font size, such as \tiny;

  • If you want to use something close to a standard fontt size, you need to allow line breaks in the text columns.

Either way, I suggest you use tabularx environments instead of minipage environments.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tabularx}
\begin{document}

\noindent
font size: tiny (50\% smaller than ``normalsize'')
\tiny
\setlength\tabcolsep{3pt} % default: 6pt

\noindent
\begin{tabularx}{0.5\textwidth}[t]{|>{\raggedright}X|l}
1-Alex Mateus Gianetti & 99981-9517 \\
2-Alinne Freitas Signorelli & 99100-6388 \\
3-Ana Claudia Perroni & 99296-5945 \\
4-Ana Estela Delgado & 98112-3965 \\
5-Ana Paula de Siqueira Faria & 99200-9854 \\
6-Ana Paula Falcão Lima & 98132-1331 \\
7-Ana Paula Santos Fava &  \\
8-André Lacerda & 99271-0340 \\
9-André Yuri de Oliveira Borges & 99262-8895 \\
10-Andreia Mantovani & 98123-7691
\end{tabularx}%
\begin{tabularx}{0.5\textwidth}[t]{|>{\raggedright}X|l|}
50-Isadora Cacho Justino & 99189-8499 \\
51-Isadora Gouveia Lara Bueno & 98435-1645 \\
52-Jeperson Pedro de Oliveira & 98152-0000 \\
53-Jéssica Melo & 99101-7979 \\
54-Joana Camargo Marchezan & 99683-5978 \\
55-João Paulo Correa da Silveira  & 99296-3438 \\
56-José Henrique Avila de Rezende & 99985-8175 \\
57-José Melo & 99951-2737 \\
58-José Rodrigues Maria & 98467-4688 \\
59-Juliane Vogel & 99241-4765 \\
60-Karina Barbosa de Alencar Oliveira & 99208-8128
\end{tabularx}

\bigskip
\normalsize\noindent
font size: small (10\% smaller than ``normalsize'')

\small
\noindent
\begin{tabularx}{0.5\textwidth}[t]{|>{\raggedright}X|l}
1-Alex Mateus Gianetti & 99981-9517 \\
2-Alinne Freitas Signorelli & 99100-6388 \\
3-Ana Claudia Perroni & 99296-5945 \\
4-Ana Estela Delgado & 98112-3965 \\
5-Ana Paula de Siqueira Faria & 99200-9854 \\
6-Ana Paula Falcão Lima & 98132-1331 \\
7-Ana Paula Santos Fava &  \\
8-André Lacerda & 99271-0340 \\
9-André Yuri de Oliveira Borges & 99262-8895 \\
10-Andreia Mantovani & 98123-7691
\end{tabularx}%
\begin{tabularx}{0.5\textwidth}[t]{|>{\raggedright}X|l|}
50-Isadora Cacho Justino & 99189-8499 \\
51-Isadora Gouveia Lara Bueno & 98435-1645 \\
52-Jeperson Pedro de Oliveira & 98152-0000 \\
53-Jéssica Melo & 99101-7979 \\
54-Joana Camargo Marchezan & 99683-5978 \\
55-João Paulo Correa da Silveira  & 99296-3438 \\
56-José Henrique Avila de Rezende & 99985-8175 \\
57-José Melo & 99951-2737 \\
58-José Rodrigues Maria & 98467-4688 \\
59-Juliane Vogel & 99241-4765 \\
60-Karina Barbosa de Alencar Oliveira & 99208-8128
\end{tabularx}
\end{document}

You must log in to answer this question.

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