5

For a table in my thesis I want to show a verti cal line only spanning 3 out of 5 columns.

My current table is:

\begin{table}[h]
\centering
\captionsetup{singlelinecheck=false}
\caption[Temperatur-Zyklus-Konditionen für präperative PCR-Reaktionen]{\textbf{Temperatur-Zyklus-Konditionen für präperative PCR-Reaktionen}}
\label{t:praeppcrcycler}
\centering
\begin{tabular}{lll}
\midrule
Temperatur & Zeit & \\
\midrule
98 \si{\degreeCelsius} & 3 min &  \\
& & \\

98 \si{\degreeCelsius} & 30 s &    \\
58 \si{\degreeCelsius} & 20-30 s & 30-35x \\
72 \si{\degreeCelsius} & 20-60 s &  \\

& & \\
72 \si{\degreeCelsius} & 3 min & \\
4 \si{\degreeCelsius} & $\infty$ & \\
\end{tabular}
\end{table}

which gives me this table enter image description here

I do however want to add a vertical line spanning column 3, row 3 to 5 as in this picture enter image description here

Any help is appreciated!

1
  • 1
    Welcome to TeX.SE, from one being from Tatooine to another! :-)
    – Mico
    Jul 5, 2017 at 20:32

3 Answers 3

7

Here it is. I slightly simplified and improved your code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{booktabs, caption, multirow, siunitx}

\begin{document}

\begin{table}[!htb]
  \captionsetup{singlelinecheck=false, justification=RaggedRight}
  \sisetup{range-phrase=--, range-units=single}
  \caption[Temperatur-Zyklus-Konditionen für präperative PCR-Reaktionen]{\textbf{Temperatur-Zyklus-Konditionen für präperative PCR-Reaktionen}}
  \label{t:praeppcrcycler}
  \centering
  \begin{tabular}{lll}
    \midrule
    Temperatur & Zeit & \\
    \midrule
    \SI {98}{\celsius} & \phantom{0}\SI{3}{min} & \\
                                     & & \\
    \SI{98}{\celsius} & \SI{30}{s} & \multicolumn{1}{|c}{} \\
    \SI{58}{\celsius} & \SIrange{20}{30}{s} & \multicolumn{1}|c}{30–35$\times$} \\
    \SI{72}{\celsius} & \SIrange{20}{60}{s} & \multicolumn{1}{|c}{} \\
                                     & & \\
    \SI{72}{\celsius}& \phantom{0}\SI{3}{min} & \\
    \phantom{0}\SI{4}{\celsius} & \phantom{0}$\infty$ & \\
    \midrule
  \end{tabular}
\end{table}

\end{document} 

enter image description here

8
  • Thanks for your help! Exactly what I was looking for. I was messing around with \multicolumn but couldn't get it quite right so this is very helpful! Also thanks for improving my code as far as siunitx is concerned - the spacing is now just as I wanted Jul 7, 2017 at 7:16
  • @Mico: How did you guess? I'll fix that. Thanks!
    – Bernard
    Jul 8, 2017 at 8:40
  • The non-ASCII-character-gremlin strikes again! (, `∞, and maybe others...)
    – Mico
    Jul 8, 2017 at 10:57
  • @Mico: Thanks, Master of the Gremlins! I tamed the ∞ gremlin. But I don't see the point with . The (utf8) endash has no problem with T1 encoding?
    – Bernard
    Jul 8, 2017 at 12:07
  • @Bernard - About the utf8-encoded en-dash character: We may never know when and how your code may get copied by somebody into their own documents -- and we won't know if they'll employ the instruction \usepackage[utf8]{inputenc}. Best not to find out...
    – Mico
    Jul 8, 2017 at 12:34
6

The following may be what you're looking for.

enter image description here

\documentclass[ngerman]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel,booktabs,siunitx}
\usepackage[skip=0.333\baselineskip,textfont=bf,
            singlelinecheck=false]{caption}
\begin{document}

\begin{table}[h]
\centering
\caption{Temperatur-Zyklus-Konditionen für präperative PCR-Reaktionen}
\label{t:praeppcrcycler}
\centering
\begin{tabular}{@{}lll@{}}
\midrule
Temperatur & Zeit & \\
\midrule
\SI{98}{\degreeCelsius} & 3\,min &  \\[2ex]
\SI{98}{\degreeCelsius} & 30\,s  &  
  \smash{\begin{tabular}[t]{|l@{}} 
            \\ 30--35$\times$ \\ \\
         \end{tabular}} \\
\SI{58}{\degreeCelsius} & 20--30\,s & \\
\SI{72}{\degreeCelsius} & 20--60\,s & \\[2ex]
\SI{72}{\degreeCelsius} & 3\,min    & \\
\SI{4}{\degreeCelsius}  & $\infty$  & \\
\bottomrule
\end{tabular}
\end{table}

\end{document}
1
  • thanks tatooine fellow! :-) Just as helpful as the solution of Bernard, which I can wrap my head around a very little bit easier though! Jul 7, 2017 at 7:15
0

Here is a solution with {NiceTabular} of nicematrix. That environment is similar to the classical environment {tabular} (of array) but creates PGF/Tikz nodes under the row, columns and cells. So it's possible to use Tikz to draw whatever rule you want after the main array by putting an instruction in the \CodeAfter (\tikz \draw (4-|3) -- (7-|3) ;).

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{ragged2e}
\usepackage{booktabs, caption, siunitx}
\usepackage{nicematrix}
\usepackage{tikz}


\begin{document}

\begin{table}[!htb]
  \captionsetup{singlelinecheck=false, justification=RaggedRight}
  \sisetup{range-phrase=--, range-units=single}
  \caption[Temperatur-Zyklus-Konditionen für präperative PCR-Reaktionen]{\textbf{Temperatur-Zyklus-Konditionen für präperative PCR-Reaktionen}}
  \label{t:praeppcrcycler}
  \centering
  \begin{NiceTabular}{lll}
    \midrule
    Temperatur & Zeit & \\
    \midrule
    \qty{98}{\celsius} & \phantom{0}\qty{3}{min} \\
                                     & & \\
    \qty{98}{\celsius} & \qty{30}{s} \\
    \qty{58}{\celsius} & \qtyrange{20}{30}{s} & 30–35$\times$ \\
    \qty{72}{\celsius} & \qtyrange{20}{60}{s} \\
                                     & & \\
    \qty{72}{\celsius}& \phantom{0}\qty{3}{min} \\
    \phantom{0}\qty{4}{\celsius} & \phantom{0}$\infty$ \\
    \midrule
  \CodeAfter \tikz \draw (4-|3) -- (7-|3) ;
  \end{NiceTabular}
\end{table}

\end{document} 

Output of the above code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.