Graphics, Figures & Tablesvertical separator line between two tables

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
mayankmi
Posts: 45
Joined: Sat Apr 20, 2013 7:52 pm

vertical separator line between two tables

Post by mayankmi »

These two tables are so near. i want to draw some vertical line so the tables look separate.

Code: Select all

\documentclass[12pt]{article}

\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}


\begin{document}


\begin{table}[h]
        \begin{minipage}{0.5\linewidth}
          \centering
          \caption{Values for granite Elastic modulus (E) for sonic velocity data (Block) generated using Monte Carlo simulation with uncertainty in poisson ratio $\nu$ and Density $\rho$}
                   \begin{tabular}{|c|c|}
\hline

Parameter & Value   \\
\hline
E & 31.51  \\
\hline
$\sigma$ & 5.06 \\
\hline
\end{tabular}
           \label{table:MCEsonic}
        \end{minipage}
        \begin{minipage}{0.5\linewidth}
           \centering
           \caption{Values for granite Elastic modulus (E) for Ultrasonic velocity data (Block) generated using Monte Carlo simulation with uncertainty in poisson ratio $\nu$ and Density $\rho$} \quad
                   \begin{tabular}{|c|c|}
\hline

Parameter & Value   \\
\hline
E & 32.20  \\
\hline
$\sigma$ & 2.16 \\
\hline
\end{tabular}
          \label{table:MCEultrasonic}
        \end{minipage}
    \end{table}

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

vertical separator line between two tables

Post by Johannes_B »

Not exactly what you wanted, but please have a look.

Code: Select all

\documentclass[12pt]{article}

\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}

\usepackage{subcaption}
\usepackage{booktabs}
\begin{document}

\begin{minipage}{0.45\linewidth}
\centering
\captionof{table}{Values for granite Elastic modulus (E) for sonic velocity data (Block) generated using Monte Carlo simulation with uncertainty in poisson ratio $\nu$ and Density $\rho$}\label{table:MCEsonic}
\begin{tabular}{cc}
\toprule
Parameter & Value   \\
\midrule
E & 31.51  \\
$\sigma$ & 5.06 \\
\bottomrule
\end{tabular}
\end{minipage}\hfil
\begin{minipage}{0.45\linewidth}
\centering
\captionof{table}{Values for granite Elastic modulus (E) for Ultrasonic velocity data (Block) generated using Monte Carlo simulation with uncertainty in poisson ratio $\nu$ and Density $\rho$} \label{table:MCEultrasonic}
\begin{tabular}{cc}
\toprule
Parameter & Value   \\
\midrule
E & 32.20  \\
$\sigma$ & 2.16 \\
\bottomrule
\end{tabular}
\end{minipage}


\begin{table}
\caption{Values for granite Elastic modulus (E) for \ref{E-sonic}~sonic and \ref{E-Usonic}~Ultrasonic velocity data (Block) generated using Monte Carlo simulation with uncertainty in poisson ratio $\nu$ and Density $\rho$}
\begin{minipage}{0.45\textwidth}
\centering
\subcaption{sonic velocity\label{E-sonic}}
\begin{tabular}{cc}
\toprule
Parameter & Value   \\
\midrule
E & 31.51  \\
$\sigma$ & 5.06 \\
\bottomrule
\end{tabular}
\end{minipage}\hfil
\begin{minipage}{0.45\textwidth}
\centering
\subcaption{ultrasonic velocity\label{E-Usonic}}
\begin{tabular}{cc}
\toprule
Parameter & Value   \\
\midrule
E & 32.20  \\
$\sigma$ & 2.16 \\
\bottomrule
\end{tabular}
\end{minipage}
\end{table}
\end{document}
Please note, how the tables are numbered. captionof is not a floating-environment, but table is. In my example the enumeration "seems" to be confused. You have to take care of things like that.

Table 3 shares the caption and is using subcaptions instead.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
mayankmi
Posts: 45
Joined: Sat Apr 20, 2013 7:52 pm

Re: vertical separator line between two tables

Post by mayankmi »

thanks ... :idea: lets see if someone comes up with solution i want
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

vertical separator line between two tables

Post by localghost »

In general vertical rules should be avoided because they disturb the reading flow (not only in tables). But you can do the following for an optical separation.
  • Decrease the width of the {minipage} environments and simply insert filling space by \hfill as Johannes already suggested.
  • Use the TeX primitive \vrule in combination with filling space by \hfill. The vertical rule will be calculated in dependence of the surrounding objects.

Code: Select all

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{caption}   % customized captions
\usepackage{booktabs}  % good looking tables
\usepackage{siunitx}   % SI units and aligned tabular material

\begin{document}
  \begin{table}[!htb]
    \begin{minipage}{0.45\linewidth}
      \centering
      \caption{Values for granite elastic modulus (E) for sonic velocity data (block) generated using Monte Carlo simulation with uncertainty in Poisson ratio $\nu$ and density $\rho$}
      \begin{tabular}{
        c
        S[table-format=2.2]
      }\toprule
        Parameter & {Value} \\ \midrule
        E & 31.51 \\
        $\sigma$ & 5.06 \\ \bottomrule
      \end{tabular}
      \label{table:MCEsonic}
    \end{minipage}
    \hfill\vrule\hfill
    \begin{minipage}{0.45\linewidth}
      \centering
      \caption{Values for granite elastic modulus (E) for ultrasonic velocity data (block) generated using Monte Carlo simulation with uncertainty in Poisson ratio $\nu$ and density $\rho$} \quad
      \begin{tabular}{
        c
        S[table-format=2.2]
      }\toprule
        Parameter & {Value} \\ \midrule
        E & 32.20 \\
        $\sigma$ & 2.16 \\ \bottomrule
      \end{tabular}
      \label{table:MCEultrasonic}
    \end{minipage}
  \end{table}
\end{document}
For the other improvements you should study the manuals of the involved packages.


Thorsten
Post Reply