TransWikia.com

incomplete vertical lines

TeX - LaTeX Asked on March 26, 2021

I have a problem with tabularx: the vertical lines don’t go all the way to the bottom: I’m guessing it’s due to adding a math equation in the 1st cell.
How can I do to have complete lines?

documentclass{article}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc} 
usepackage[french]{babel}
usepackage[left=1.5cm, right=1.5cm, top=1.5cm, bottom=1.5cm]{geometry}
usepackage{tabularx}

begin{tabularx}{linewidth}{|c||*{7}{>{centering arraybackslash}X|}}hline
    volume d'eau (L)& 0.3 & 0.5 & 0.7 & 0.9 & 1.1 & 1.3 & 1.5  
    hline
    force (N) & 3 & 5 & 7 & 9 & 11 & 13 & 15   
    hline 
    Résistance ($textrm{k}Omega$) &  &  &  &  & & & &  
    hline
    end{tabularx}
end{document}

Thanks for your help

2 Answers

There was a spurious & in the last line. I also suggest a slightly different layout, where the double vertical line interrupts the inner horizontal lines, which can be obtained with hhline, some vertical padding at the top of cells with extrarowheight, and a simpler way to typeset with siunitx.

documentclass{article}

usepackage[T1]{fontenc}
usepackage[french]{babel}
usepackage[margin=1.5cm]{geometry}
 usepackage{tabularx}
 usepackage{hhline}
usepackage{siunitx}

begin{document}

setlength{extrarowheight}{2pt}
noindentbegin{tabularx}{linewidth}{|c||*{7}{>{centering arraybackslash}X|}}
    hline
    volume d'eau (L)& 0.3 & 0.5 & 0.7 & 0.9 & 1.1 & 1.3 & 1.5 
    hline
    force (N) & 3 & 5 & 7 & 9 & 11 & 13 & 15 
    hline
    Résistance (si{kohm}) & & & & & & & 
    hline
    end{tabularx}
vskip 1cm

noindentbegin{tabularx}{linewidth}{|c||*{7}{>{centering arraybackslash}X|}}
    hline
    volume d'eau (L)& 0.3 & 0.5 & 0.7 & 0.9 & 1.1 & 1.3 & 1.5 
    hhline{-||-------}
    force (N) & 3 & 5 & 7 & 9 & 11 & 13 & 15 
    hhline{-||-------}
    Résistance (si{kohm}) & & & & & & & 
    hline
    end{tabularx}

end{document} 

enter image description here

Correct answer by Bernard on March 26, 2021

If I add the missing begin{document} and try to compile your code, I end up with an error message such as

Extra alignment tab has been changed to cr.

which tells us that there is an extra & somewhere in your table.

As soon as you get an error message, do not look at the resulting .pdf document. Even if you get something that on first glance resembles a pdf file, there can still be issues with it. After an error, TeX only tries to recover enough to syntax check more of the file, it does not try to make sensible output after an error.

To get rid of the error message, delete the last & from the "Résistance" row and you will end up with a compilable example resulting in the following output. Such an extra &can be spotted more easily if you align all &s in your code, just as I did in the below MWE.

enter image description here

Additionally, I recommend using the siunitx package for the units, as shown in the following example code:

documentclass{article}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc} 
usepackage[french]{babel}
usepackage[left=1.5cm, right=1.5cm, top=1.5cm, bottom=1.5cm]{geometry}
usepackage{tabularx}

usepackage{siunitx}

begin{document}
begin{tabularx}{linewidth}{|c||*{7}{>{centering arraybackslash}X|}}hline
    volume d'eau (si{liter})  & 0.3 & 0.5 & 0.7 & 0.9 & 1.1 & 1.3 & 1.5  
    hline
    force (si{newton})        & 3   & 5   & 7   & 9   & 11  & 13  & 15   
    hline 
    Résistance (si{kiloohm}) &     &     &     &     &     &     &     
    hline
    end{tabularx}
end{document}

Answered by leandriis on March 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP