0

I want to create a document with three tables inside minipage environments. See MWE below.

While I do get three tables side by side, the contents of these tables overlap. One way to get rid of these could be if the longer cells get line break inside a cell.

MWE

\documentclass{article}
\usepackage[demo]{graphicx}
%\usepackage{tcolorbox}
\usepackage{tabularx}

\begin{document}

\fbox{ \begin{minipage}{.3\textwidth} OT goods for CA-GB \rule{\textwidth}{0.9pt} \begin{center} \begin{tabular}{ lr } Inj Stacef-1g & 2 \ Disposable syringes-5ml & 5 \
Shi mediwear gown & 5 \end{tabular} \end{center}

\end{minipage}%

} \fbox{ \begin{minipage}{.3\textwidth} OT goods for CA-GB \rule{\textwidth}{0.9pt} \begin{center} \begin{tabular}{ lr } Inj Stacef-1g & 2 \ Disposable syringes-5ml & 5 \
Shi mediwear gown & 5 \end{tabular} \end{center}

\end{minipage}%

} \fbox{ \begin{minipage}{.3\textwidth} OT goods for CA-GB \rule{\textwidth}{0.9pt} \begin{center} \begin{tabular}{ lr } Inj Stacef-1g & 2 \ Disposable syringes-5ml & 5 \
Shi mediwear gown & 5 \end{tabular} \end{center}

\end{minipage}%

} \end{document}

enter image description here

How can I keep these three tables side by side, yet avoid overlapping? Any workaround or a complete new way to achieve this?

Suman
  • 235
  • 2
    lr are both single line entries so you either need to use a smaller font size or change l to p{2cm} or whatever width you want. This is a duplicate of https://tex.stackexchange.com/questions/332902/my-table-doesnt-fit-what-are-my-options/332903#332903 – David Carlisle Jan 12 '21 at 19:04

1 Answers1

2

Tables can be enhanced in many way. This is one possibility to fit the three tables without changing the font size. The \arraystretch expands the cell vertically. The \multirow in the first line enhances the title. The type P column allows for longer sentences in a fixed width cell, as in the second line.

The \tabcolsep controls the separation between the two columns. You might play with different values of \tabcolsep and the width of the minipage.

abc

\documentclass{article}

\usepackage{array} \usepackage{multirow}

\newcolumntype{P}[1]{>{\raggedright\arraybackslash}m{#1\textwidth}}

\begin{document}

\renewcommand{\arraystretch}{1.4} \setlength{\tabcolsep}{4pt}

\begin{minipage}{0.25\textwidth}
\begin{tabular}{|P{1} c|}
\hline
\multicolumn{2}{|c|}{\multirow{2}{}{OT goods for CA-GB}} \ & \ \hline Inj Stacef-1g & 2\ Disposable syringes-5ml & 5\
Shi mediwear gown & 5 \ \hline \end{tabular}
\end{minipage}\hfill
\begin{minipage}{0.25\textwidth}
\begin{tabular}{|P{1} c|}
\hline
\multicolumn{2}{|c|}{\multirow{2}{
}{OT goods for CA-GB}} \ &\ \hline Inj Stacef-1g & 2\ Disposable syringes-5ml & 5\
Shi mediwear gown & 5 \ \hline \end{tabular}
\end{minipage}\hfill
\begin{minipage}{0.25\textwidth}
\begin{tabular}{|P{1} c|}
\hline
\multicolumn{2}{|c|}{\multirow{2}{*}{OT goods for CA-GB}} \ &\ \hline Inj Stacef-1g & 2\ Disposable syringes-5ml & 5\
Shi mediwear gown & 5 \ \hline \end{tabular}
\end{minipage} \end{document}

Simon Dispa
  • 39,141