1

I want to join two edges of two tables such that the tables are side-by-side i.e. Table A edge right with Table B edge left. I know the thread How can I have two tables side by side? but I want specificially join the edges i.e. they touch and share a common bold edge. Code and its output in Fig. 1

\documentclass{article}
\usepackage[english]{babel}
\usepackage[margin=0pt]{geometry}% http://ctan.org/pkg/geometry

\begin{document}

    % https://en.wikibooks.org/wiki/LaTeX/Tables
    \begin{tabular}{ | l | l | l | p{3cm} |}
    \hline
    Day & Min Temp & Max Temp & Summary \\ \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.
    However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
    across most of Scotland and Northern Ireland,
    but rain reaching the far northwest. \\ \hline
    Wednesday & 10C & 21C & Rain will still linger for the morning.
    Conditions will improve by early afternoon and continue
    throughout the evening. \\
    \hline
    \end{tabular}

    \begin{tabular}{ | l | l | l | p{3cm} |}
    \hline
    Day & Min Temp & Max Temp & Summary \\ \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.
    However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
    across most of Scotland and Northern Ireland,
    but rain reaching the far northwest. \\ \hline
    Wednesday & 10C & 21C & Rain will still linger for the morning.
    Conditions will improve by early afternoon and continue
    throughout the evening. \\
    \hline
    \end{tabular}

\end{document}

Fig. 1 Output

enter image description here

Expected output: two tables at the same row such that the common wall/edge is bold as clear separator

Another example as 1x3 with 4 tables

Show 1x3 table structure i.e. one table at the left-hand-side and there tables at the right-hand-side such that many common edges. Code and its output in Fig. 2

\documentclass{article}
\usepackage[english]{babel}
\usepackage[margin=0pt]{geometry}% http://ctan.org/pkg/geometry

\begin{document}

    \begin{tabular}{ | l | l | l | p{3cm} |}
    \hline
    Day & Min Temp & Max Temp & Summary \\ \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.
    However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
    across most of Scotland and Northern Ireland,
    but rain reaching the far northwest. \\ \hline
    Wednesday & 10C & 21C & Rain will still linger for the morning.
    Conditions will improve by early afternoon and continue
    throughout the evening. \\
    \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.
    However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
    across most of Scotland and Northern Ireland,
    but rain reaching the far northwest. \\ \hline
    Wednesday & 10C & 21C & Rain will still linger for the morning.
    Conditions will improve by early afternoon and continue
    throughout the evening. \\
    \hline
    \end{tabular}

    \begin{tabular}{ | l | l | l | p{3cm} |}
    \hline
    Day & Min Temp & Max Temp & Summary \\ \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.
    However, the strong breeze will bring down the temperatures. \\ \hline
    \end{tabular}

    \begin{tabular}{ | l | l | l | p{3cm} |}
    \hline
    Day & Min Temp & Max Temp & Summary \\ \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.
    However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
    across most of Scotland and Northern Ireland,
    but rain reaching the far northwest. \\ \hline
    \end{tabular}

    \begin{tabular}{ | l | l | l | p{3cm} |}
    \hline
    Day & Min Temp & Max Temp & Summary \\ \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.
    However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
    across most of Scotland and Northern Ireland,
    but rain reaching the far northwest. \\ \hline
    \end{tabular}

\end{document}

Fig. 2 Output of 1x3 table structure with 4 tables

enter image description here

Expected output: 1x3 table structure where 4 tables

Testing Heiko's approach with 1x3 structure

Code where the last table is wrongly shown at the left-hand side in Fig. 3

\documentclass{article}
\usepackage[english]{babel}
\usepackage[margin=0pt]{geometry}% http://ctan.org/pkg/geometry

\usepackage{microtype}% more flexibility for narrow columns
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{siunitx}

\newcommand*{\MakeCell}[1]{%
  \begingroup
    \renewcommand*{\arraystretch}{1}% reset if changed
    \begin{tabular}[b]{@{}c@{}}%
    #1%
    \end{tabular}%
  \endgroup
}

\begin{document}

\noindent
    \begin{tabularx}{.50\linewidth}[t]{ | l | l | l | X | }
    \hline
    Day & Min Temp & Max Temp & Summary \\ \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.
    However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
    across most of Scotland and Northern Ireland,
    but rain reaching the far northwest. \\ \hline
    Wednesday & 10C & 21C & Rain will still linger for the morning.
    Conditions will improve by early afternoon and continue
    throughout the evening. \\
    \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.
    However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
    across most of Scotland and Northern Ireland,
    but rain reaching the far northwest. \\ \hline
    Wednesday & 10C & 21C & Rain will still linger for the morning.
    Conditions will improve by early afternoon and continue
    throughout the evening. \\
    \hline
    \end{tabularx}%
\kern-.2pt %
\vrule % default width is 0.4 pt
\kern-.2pt %
    \begin{tabularx}{.50\linewidth}[t]{ | l | l | l | X | }
    \hline
    Day & Min Temp & Max Temp & Summary \\ \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.
    However, the strong breeze will bring down the temperatures. \\ \hline
    \end{tabularx}
\kern-.2pt %
\vrule % default width is 0.4 pt
\kern-.2pt %
    \begin{tabularx}{.50\linewidth}[t]{ | l | l | l | X | }
    \hline
    Day & Min Temp & Max Temp & Summary \\ \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.
    However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
    across most of Scotland and Northern Ireland,
    but rain reaching the far northwest. \\ \hline
    \end{tabularx}
\kern-.2pt %
\vrule % default width is 0.4 pt
\kern-.2pt %
    \begin{tabularx}{.50\linewidth}[t]{ | l | l | l | X | }
    \hline
    Day & Min Temp & Max Temp & Summary \\ \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.
    However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
    across most of Scotland and Northern Ireland,
    but rain reaching the far northwest. \\ \hline
    \end{tabularx}  
\kern-.2pt %
\vrule % default width is 0.4 pt
\kern-.2pt %
    \begin{tabularx}{.50\linewidth}[t]{ | l | l | l | X | }
    \hline
    Day & Min Temp & Max Temp & Summary \\ \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.
    However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
    across most of Scotland and Northern Ireland,
    but rain reaching the far northwest. \\ \hline
    \end{tabularx}  
    % TODO why this last is wrongly put to the left-hand-side

\end{document}

Output in Fig. 3 where wrongly shown the last table at the left-hand-side

Fig. 3 Output

enter image description here

OS: Debian 9
TeXLive: 2017

1 Answers1

3

A variant for two tables side by side:

  • Environment tabularx of package tabularx for the X column to maximize the place for the column with the summary.

  • Nicer lines with package booktabs

  • Units with package siunitx

  • ...

Example file:

\documentclass{article}
\usepackage{microtype}% more flexibility for narrow columns
\usepackage[english]{babel}
\usepackage[margin=0pt]{geometry}% http://ctan.org/pkg/geometry
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{siunitx}

\newcommand*{\MakeCell}[1]{%
  \begingroup
    \renewcommand*{\arraystretch}{1}% reset if changed
    \begin{tabular}[b]{@{}c@{}}%
    #1%
    \end{tabular}%
  \endgroup
}

\begin{document}

    \noindent
    \begin{tabularx}{.49\linewidth}[t]{ l l l X }
    \toprule
    Day & \MakeCell{Min.\\temp.} & \MakeCell{Max.\\temp.} & Summary \\
    \midrule
    Monday & \SI{11}{\celsius} & \SI{22}{\celsius}
    & A clear day with lots of sunshine.
      However, the strong breeze will bring down the temperatures. \\
    \addlinespace
    Tuesday & \SI{9}{\celsius} & \SI{19}{\celsius}
    & Cloudy with rain, across many northern
      regions. Clear spells
      across most of Scotland and Northern Ireland,
      but rain reaching the far northwest. \\
    \addlinespace
    Wednesday & \SI{10}{\celsius} & \SI{21}{\celsius}
    & Rain will still linger for the morning.
      Conditions will improve by early afternoon and continue
      throughout the evening. \\
    \bottomrule
    \end{tabularx}%
    \hfill
    \begin{tabularx}{.49\linewidth}[t]{ l l l X }
    \toprule
    Day & \MakeCell{Min.\\temp.} & \MakeCell{Max.\\temp.} & Summary \\
    \midrule
    Monday & \SI{11}{\celsius} & \SI{22}{\celsius}
    & A clear day with lots of sunshine.
      However, the strong breeze will bring down the temperatures. \\
    \addlinespace
    Tuesday & \SI{9}{\celsius} & \SI{19}{\celsius}
    & Cloudy with rain, across many northern
      regions. Clear spells
      across most of Scotland and Northern Ireland,
      but rain reaching the far northwest. \\
    \addlinespace
    Wednesday & \SI{10}{\celsius} & \SI{21}{\celsius}
    & Rain will still linger for the morning.
      Conditions will improve by early afternoon and continue
      throughout the evening. \\
    \bottomrule
    \end{tabularx}

\end{document}

Result

With a vertical rule instead of padding to separate the tables:

\end{tabularx}%
\kern-.2pt %
\vrule % default width is 0.4 pt
\kern-.2pt %
\begin{tabularx}{.5\linewidth}[t]{ l l l X }

Result with vertical rule

Variant with one large table on the left and three small tables at the right:

\documentclass{article}
\usepackage{xcolor}
\begin{document}

\newcommand*{\TableA}{%
  \textcolor{gray}{\rule{.5\linewidth}{10cm}}%
}
\newcommand*{\TableB}{%
  \textcolor{red}{\rule{.5\linewidth}{3cm}}%
}
\newcommand*{\TableC}{%
  \textcolor{green}{\rule{.5\linewidth}{3cm}}%
}
\newcommand*{\TableD}{%
  \textcolor{blue}{\rule{.5\linewidth}{3cm}}%
}
\sbox0{\TableA}%
\noindent
\vtop{%
  \kern0pt % Align at the top
  \copy0 %
}%
\kern-.2pt %
\vrule
\kern-.2pt %
\vtop to \dimexpr\ht0+\dp0{%
  \kern0pt % Align at the top
  \hbox{\TableB}%
  \vfill
  \hbox{\TableC}%
  \vfill
  \hbox{\TableD}%
}
\end{document}

Result

Other variant:

\documentclass{article}
\usepackage{xcolor}
\begin{document}

\newcommand*{\TableA}{%
  \textcolor{gray}{\rule{.5\linewidth}{10cm}}%
}
\newcommand*{\TableB}{%
  \textcolor{red}{\rule{.5\linewidth}{3cm}}%
}
\newcommand*{\TableC}{%
  \textcolor{green}{\rule{.5\linewidth}{3cm}}%
}
\newcommand*{\TableD}{%
  \textcolor{blue}{\rule{.5\linewidth}{3cm}}%
}
\noindent
\vtop{%
  \kern0pt % Align at the top
  \hbox{\TableA}%
}%
\kern-.2pt %
\vrule
\kern-.2pt %
\vtop{%
  \kern0pt % Align at the top
  \hbox{\TableB}%
  \nointerlineskip
  \hbox{\TableC}%
  \nointerlineskip
  \hbox{\TableD}%
}
\end{document}

Result

Heiko Oberdiek
  • 271,626