0

how can I get rid of the vertical line in the first row? I would like it to only extend from SI to base. While were at it, I also would like to know, if it's possible to define the '\hline' more precisely, say that it only should go from W to E.

I'm still very new to latex so i am not very familiar with lots of packages

This is what I have:

\usepackage{siunitx}
\begin{document}
\begin{tabular}{||c| c c c c c c||}
    \hline
     & W & Q & U & C & E & $\epsilon_0$\\ \hline\hline
    SI & \si{\joule} & \si{\coulomb} & \si{\volt} & \si{\farad} & \si{\volt\per\meter} & \si{\coulomb\per\volt\per\meter}\\ \hline
    base  &
\end{tabular}
\end{document}

enter image description here

2
  • 1
    For shorter \hlines, use \cline{2-7} (the argument takes two integers separated by a dash, the first integer denoting the column where the line should start, the second where the line should end. Apr 1 at 12:25
  • Off-topic: before you try invent own fancy table layout I would consult this page: wiert.me/2014/04/03/…. ... so you may omit vertical lines completely and for horizontal lines use rules defined in booktabs package or rules which enables tabularray package.
    – Zarko
    Aug 29 at 14:59

1 Answer 1

0

Shorter lines in tables can be obtained via \cline which takes two integers separated by a dash in its argument, the first integer denoting the column where the line should start, the second integer denoting the column where the line should end.

However, I think you want to combine such a shorter line with a \hline that spans over all columns. Sadly, \cline{2-7}\hline would not work, but you can make use of the macro \hhline provided by the hhline package:

\documentclass{article}
\usepackage{siunitx}
\usepackage{hhline}
\begin{document}
\begin{tabular}{||c| c c c c c c||}
    \cline{2-7}
    \multicolumn{1}{c|}{} & W & Q & U & C & E & $\epsilon_0$\\ 
    \hhline{-======}
    SI   & \si{\joule} & \si{\coulomb} & \si{\volt} & \si{\farad} & \si{\volt\per\meter} & \si{\coulomb\per\volt\per\meter}\\ 
    \hline
    base &  &  &  &  &  &  \\ 
    \hline
\end{tabular}
\end{document}

enter image description here

If you want to remove the vertical line left of "W", you can go like this:

\documentclass{article}
\usepackage{siunitx}
\usepackage{hhline}
\begin{document}
\begin{tabular}{||c| c c c c c c||}
    \cline{2-7}
    \multicolumn{1}{c}{} & W & Q & U & C & E & $\epsilon_0$\\ 
    \hhline{-======}
    SI   & \si{\joule} & \si{\coulomb} & \si{\volt} & \si{\farad} & \si{\volt\per\meter} & \si{\coulomb\per\volt\per\meter}\\ 
    \hline
    base &  &  &  &  &  &  \\ 
    \hline
\end{tabular}
\end{document}

enter image description here


Maybe also have a look at the tabularray package which provides more flexibility when it comes to cell borders (and provides for better spacing in my opinion):

\documentclass{article}
\usepackage{tabularray}
\usepackage{siunitx}
\begin{document}
\begin{tblr}{ 
    colspec = { *{7}{c} },
    hline{1} = {1}{2-Z}{},
    hline{2} = {1}{2-Z}{},
    hline{2-Z} = {2}{1-Z}{},
    vline{1} = {1}{2-Z}{},
    vline{1} = {2}{2-Z}{},
    vline{2,Z} = {1}{1-Z}{},
    vline{Z} = {2}{1-Z}{},
}
         & W & Q & U & C & E & $\epsilon_0$ \\ 
    SI   & \si{\joule} & \si{\coulomb} & \si{\volt} & \si{\farad} & \si{\volt\per\meter} & \si{\coulomb\per\volt\per\meter} \\ 
    base &  &  &  &  &  &  \\ 
\end{tblr}
\end{document}

enter image description here

2
  • thanks a lot. now that answered my question to shortend \hlines, but how can i create shortler \vlines? Basically, removing the line beside 'W', but having a line from 'SI' to 'Base'? By using \begin{tabular}{||c| c c c c c c||}, it puts a line through all the rows and I would like to avoid that
    – 434dx
    Apr 1 at 12:45
  • @434dx You can only skip a vertical line using a \multicolumn that only spans one cell and takes a column defintion without a vertical line. Apr 1 at 13:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .