3

I've seen the answer someone posted and I implemented it, I would like to keep this configuration as I already based my word using this answer.
Now, the question is, how can I make partial horizontal lines like what does \cline{-}.

1
  • \cmidrule from booktabs has an optional argument (if I remember well).
    – Manuel
    Apr 26, 2014 at 0:33

3 Answers 3

5

In the following, we define a new version of \cline as \Cline where you can provide the required thickness.

\documentclass{article}

\makeatletter
\def\Cline#1#2{\@Cline#1#2\@nil}
\def\@Cline#1-#2#3\@nil{%
  \omit
  \@multicnt#1%
  \advance\@multispan\m@ne
  \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
  \@multicnt#2%
  \advance\@multicnt-#1%
  \advance\@multispan\@ne
  \leaders\hrule\@height#3\hfill
  \cr}
\makeatother


\begin{document}

\begin{tabular}{ccc}
  \hline
  A & B & C\\\hline
  D & E & F\\
  \Cline{1-2}{5.0pt}
  G & H & I\\
  \Cline{1-2}{2.0pt}
  J & K & L\\
  \cline{1-2}
\end{tabular}

\end{document}

As can see, you are in control of the thickness when you use \Cline.

enter image description here

And the non-thick standard \cline is always there.

Should need all your \clines (and other lines) to be thick, change \arrayrulewidth to some value you wish.

4
  • thanks for the reply, but is there a way of fix the height of the cells, please have a loook at the G and H squares, the letters are almost lost.
    – Hans
    Apr 26, 2014 at 0:32
  • Yes, see the updated answer.
    – Masroor
    Apr 26, 2014 at 0:50
  • I would like to understand all that you did, is there a book you advice me to learn all this? (btw, accepted answer).
    – Hans
    Apr 26, 2014 at 0:54
  • The knowledge which played the major role was understanding LaTeX macros. I learned mine from The TeXBook, Chapter 20. But you can try this one as well. And remember, there are no quick ways, initial days have very steep curves. Sounds pedantic? Meant to be.
    – Masroor
    Apr 26, 2014 at 3:05
6

The makecell package already has, among many other features, the Xhline and \Xcline commands. Examples of use:

\Xhline{1.2pt}
\Xcline{3-6}{2pt}

Excerpt from the doc:

0

With nicematrix, you can define for the environments of nicematrix ({NiceTabular}, {NiceArray}, {NiceMatrix}), a command in the style of \cline which will draw a rule by using TikZ (all characteristics allowed by TikZ are available for your rule).

\documentclass{article}
\usepackage{nicematrix,tikz}

\NiceMatrixOptions
  {
    custom-line = 
     {
       ccommand = Cline , 
       tikz = { line width = 2 pt } , 
       total-width = 2 pt % horizontal space reserved for the rule
     }
  }

\begin{document}

\begin{NiceTabular}{ccc}
  \hline
  A & B & C\\\hline
  D & E & F\\
  \Cline{1-2}
  G & H & I\\
  J & K & L\\
  \cline{1-2}
\end{NiceTabular}

\end{document}

You need several compilations.

Output of the above code

You must log in to answer this question.

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