3

I am working on a scientific project, and it involves tabulating my results. I am using tabu environment, but when I create an empty cell on the first line, the left vertical border of the empty cell still remains. Why does this happen and how do I fix it? Thanks.

Here is my code:

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

\usepackage{geometry}
\geometry{a4paper}
\geometry{margin=2cm}

\usepackage{graphicx}

\usepackage{booktabs}
\usepackage{array}
\usepackage{paralist}
\usepackage{verbatim}
\usepackage{subfig}

\usepackage{fancyhdr}
\usepackage{lastpage}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\lhead{}\chead{}\rhead{}
\lfoot{}\cfoot{\thepage ~of \pageref{LastPage}}\rfoot{}

\usepackage[nottoc,notlof,notlot]{tocbibind}
\usepackage[titles,subfigure]{tocloft}
\renewcommand{\cftsecfont}{\rmfamily\mdseries\upshape}
\renewcommand{\cftsecpagefont}{\rmfamily\mdseries\upshape}

\usepackage[version=4]{mhchem}
\usepackage{tikz}
\usepackage{float}
\usepackage{siunitx}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{makecell}
\usepackage{multirow}
\usepackage{setspace}
\onehalfspacing
\usepackage[backend=biber, style=chem-acs, citestyle=authoryear]{biblatex}
\bibliography{Biblio} %%%"Biblio" is my .bib file.



\begin{document}

\begin{table}[H]
\centering
\begin{tabu} to 1.1\textwidth{| X[l] | X[l] | X[l] | X[l] | X[c] | X[c] |}
%\tabulinesep{2pt}
\cline{2-6}
& \multicolumn{3}{ c |}{Voltage measured (V)} & \multirow{2}{*}{\thead{Mean\\ voltage (V)}} & \multirow{2}{*}{\thead{Standard\\ deviation}}\\
\cline{1-4}
Temperature (\SI{}{\degree}C) & Replicate 1 & Replicate 2 & Replicate 3 & &\\
\hline
10 & 1.79 & 1.78 & 1.79 & $\frac{1.79+1.78+1.79}{3}=1.78$ & 0.00577\\
\hline
30 & 1.82 & 1.83 & 1.84 & $\frac{1.82+1.83+1.84}{3}=1.83$ & 0.01\\
\hline
50 & 1.92 & 1.93 & 1.90 & $\frac{1.92+1.93+1.90}{3}=1.92$ & 0.0152\\
\hline
70 & 1.88 & 1.86 & 1.85 & $\frac{1.88+1.86+1.85}{3}=1.86$ & 0.0152\\
\hline
90 & 1.73 & 1.76 & 1.77 & $\frac{1.73+1.76+1.77}{3}=1.75$ & 0.0208\\
\hline
\end{tabu}
\caption{Table of raw data}
\label{tbl:rawdata}
\end{table}

\end{document}

This gives me the following table:

enter image description here

I have circled the offending margin in the above photo.

ebosi
  • 11,692
Victor Z
  • 383

1 Answers1

2

The issue is caused by the global definition of the table (\textwidth{| X[l] | X[l] | X[l] | X[l] | X[c] | X[c] |}) that created a vertical line for each column.

The trick is to override this behavior by creating a "one-column multicolumn-cell". Indeed, multicols allows you to redefine the style of this particular column. You should thus add \multicolumn{1}{c|}{} in the first cell.


\documentclass[11pt]{article}
    \usepackage[utf8]{inputenc}
    \usepackage{booktabs}
    \usepackage{array}
    \usepackage{siunitx}
    \usepackage{tabu}
    \usepackage{longtable}
    \usepackage{makecell}
    \usepackage{multirow}
\begin{document}
    \begin{table}
        \centering
        \begin{tabu} to 1.1\textwidth{| X[l] | X[l] | X[l] | X[l] | X[c] | X[c] |}
            \cline{2-6}
            \multicolumn{1}{c|}{} & \multicolumn{3}{c|}{Voltage measured (V)} & \multirow{2}{*}{\thead{Mean\\ voltage (V)}} & \multirow{2}{*}{\thead{Standard\\ deviation}}\\
            \cline{1-4}
            Temperature (\SI{}{\degree}C) & Replicate 1 & Replicate 2 & Replicate 3 & &\\
            \hline
            10 & 1.79 & 1.78 & 1.79 & $\frac{1.79+1.78+1.79}{3}=1.78$ & 0.00577\\
            \hline
        \end{tabu}
    \end{table}
\end{document}

P.S.:

  • The example you used was far from minimal, i.e., much of your code does not seem to be relevant to the question you're asking here. Please limit the example to only the code required for your issue to appear. You can have a look at this guide for how to prune your code for this purpose, and this one to know more about minimal working example (MWE).
  • You was loading booktabs. It is indeed a great package for arrays. Don't hesitate to use \toprule, \midrule and \bottomrule in your tables. (Using booktab's approach (i.e. no vertical lines) might also be a mean to avoid such issues.
  • I'm not familiar with tabu, since I have barely seen it. You might want to have a look at some other packages (notably tabularx and tabulary have similar features). (I however don't know if they are better or not.)
ebosi
  • 11,692