Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

\cline, \hline, \midrule, \cmidrule

2,010 views
Skip to first unread message

minimus

unread,
Nov 21, 2011, 6:52:43 AM11/21/11
to
I decided to carry the issue to a new thread as I think it might be useful
to discuss what is happening with hline, cline, midrules:

In the minimal example below, I made four examples. What I want is the the
text between the horizontal lines are centered vertically.

\hline and \cline do not really center the text vertically.

\midrule or \cmidrule center the the text vertically. So I would go for
these commands but now, for some reason, the column lines do not touch the
row lines.

Hence my questions:

1. How can I make the text vertically centered while using \hline or
\cline?

2. If 1 is not possible, how can I make the column lines touch the row lines
while using \midrule or \cmidrule?





\documentclass{article}
\usepackage{array, booktabs}
\begin{document}

\begin{tabular}{ | m{2cm} | *{11}{m{0.5cm} | } }
\hline
Age & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 & 71 & 72
\\
\hline
\end{tabular}

\begin{tabular}{ | m{2cm} | *{11}{m{0.5cm} | } }
\cline{1-12}
Age & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 & 71 & 72
\\
\cline{1-12}
\end{tabular}

\begin{tabular}{ | m{2cm} | *{11}{m{0.5cm} | } }
\midrule[0.04em]
Age & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 & 71 & 72
\\
\midrule[0.04em]
\end{tabular}

\begin{tabular}{ | m{2cm} | *{11}{m{0.5cm} | } }
\cmidrule(r){1-12}
Age & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 & 71 & 72
\\
\cmidrule(r){1-12}
\end{tabular}

\end{document}

Lars Madsen

unread,
Nov 21, 2011, 7:01:01 AM11/21/11
to
minimus wrote, On 2011-11-21 12:52:
> I decided to carry the issue to a new thread as I think it might be
> useful to discuss what is happening with hline, cline, midrules:
>
> In the minimal example below, I made four examples. What I want is the
> the text between the horizontal lines are centered vertically.
>
> \hline and \cline do not really center the text vertically.
>
> \midrule or \cmidrule center the the text vertically. So I would go for
> these commands but now, for some reason, the column lines do not touch
> the row lines.
>
> Hence my questions:
>
> 1. How can I make the text vertically centered while using \hline or
> \cline?
>
> 2. If 1 is not possible, how can I make the column lines touch the row
> lines while using \midrule or \cmidrule?
>

In general, don't use vertical lines. They do not contribute anything to
the understanding of the data. (this is one of the sideeffects of the
booktabs lines, they do not work with vertical lines, thus forcing
authors to prepare data differently).

Reference: Bringhurst: The Elements of Typographic Style (booktabs are
build on these recommendations)

or see the tables presented in the Chicago Manual of Style.

Neither is using vertical lines in their data tables.

I like this quote from Bringhurst:

Tables are notoriously time-consuming
to typeset, but the problems posed are often editorial as much as
typographic. If the table is not planned in a readable form to
begin with, the typographer can render it readable only by
rewriting or redesigning it from scratch.

If the lines are used as column deviders, a similar 'virtual' effect can
be achieved using space between the columns


>
>
>
>
> \documentclass{article}
> \usepackage{array, booktabs}
> \begin{document}
>
> \begin{tabular}{ | m{2cm} | *{11}{m{0.5cm} | } }
> \hline
> Age & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 & 71 & 72 \\
> \hline
> \end{tabular}
>
> \begin{tabular}{ | m{2cm} | *{11}{m{0.5cm} | } }
> \cline{1-12}
> Age & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 & 71 & 72 \\
> \cline{1-12}
> \end{tabular}
>
> \begin{tabular}{ | m{2cm} | *{11}{m{0.5cm} | } }
> \midrule[0.04em]
> Age & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 & 71 & 72 \\
> \midrule[0.04em]
> \end{tabular}
>
> \begin{tabular}{ | m{2cm} | *{11}{m{0.5cm} | } }
> \cmidrule(r){1-12}
> Age & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 & 71 & 72 \\
> \cmidrule(r){1-12}
> \end{tabular}
>
> \end{document}


--

/daleif (remove RTFSIGNATURE from email address)

Memoir and mh bundle maintainer
LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.minimalbeispiel.de/mini-en.html

minimus

unread,
Nov 21, 2011, 7:09:25 AM11/21/11
to
"Lars Madsen" wrote in message
news:4eca3d7d$0$282$1472...@news.sunsite.dk...
I have to use the vertical lines. I simplified the tables in y minimal
example. There is more beneath the age lines. Hence, I need the vertical
lines.

I appreciate your comments but my problem is not solved :-)


Lars Madsen

unread,
Nov 21, 2011, 7:13:17 AM11/21/11
to
> I have to use the vertical lines. I simplified the tables in y
minimal > example. There is more beneath the age lines. Hence, I need the
> vertical lines.

> I appreciate your comments but my problem is not solved


no you do not need those, please provide a 'real' example, and I'll show
you what I usually do.

minimus

unread,
Nov 21, 2011, 7:20:27 AM11/21/11
to
"Lars Madsen" wrote in message
news:4eca405d$0$282$1472...@news.sunsite.dk...
My minimal example is exactly what I am trying to do. The rest of the table,
which I did not present, is not relevant. So could you please show me what
you usually do in the example I have given. All I want is vertically
centered text between row lines and I need the vertical lines too.




Lars Madsen

unread,
Nov 21, 2011, 7:24:53 AM11/21/11
to
In that case I cannot help with that requirement.

I'd also recommend not to vertical center. (it is a lot easier not to)

In your example, I do not see the need for any vertical centering.

minimus

unread,
Nov 21, 2011, 7:29:40 AM11/21/11
to
"Lars Madsen" wrote in message
news:4eca4315$0$282$1472...@news.sunsite.dk...
The text is just not vertically centered between the horizontal lines. The
text is more close to the upper horizontal line. What do you mean by "not
see the need"? This is a technical question. The text should be vertically
centered. But it is not. And I am asking why.



Lars Madsen

unread,
Nov 21, 2011, 7:33:22 AM11/21/11
to
could you please stop writing in the signature area, I cannot quote your
text

> The text is just not vertically centered between the horizontal
lines. > The text is more close to the upper horizontal line. What do
you mean > by "not see the need"? This is a technical question. The text
should
> be vertically centered. But it is not. And I am asking why.

no answer. I do not see the problem, when one is not using the m
columns, and I do not see any reason to use m columsn in this case. Why
should the contetns no be on the same baseline?

minimus

unread,
Nov 21, 2011, 7:36:24 AM11/21/11
to
"Lars Madsen" wrote in message
news:4eca4512$0$282$1472...@news.sunsite.dk...
Sorry did not understand what you mean here. I use m so that the text is
vertically centered. (no I don’t use p{} or b{}).

And the problem is clear: the text is not vertically centered. So HOW to
center the text vertically between the horizontal lines???




Enrico Gregorio

unread,
Nov 21, 2011, 7:46:58 AM11/21/11
to
You seem not to notice that the rows /are/ "vertically centered":
in the first sample there is as much space above the "A" as below
the "g". Of course this shows the numbers as "too high".

Using "m" columns doesn't help. Rather, use

\setlength{\extrarowheight}{1.5pt}

as shown here

\begin{table}
\setlength{\extrarowheight}{1.5pt}
\centering
\begin{tabular}{ | p{2cm} | *{11}{>{\centering\arraybackslash}p{0.5cm}
| } }
\hline
Age & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 & 71 & 72
\\
\hline
\end{tabular}
\end{table}

In this way the entries will be centered.

However, the rest of the table /is/ relevant if you wish
advice about improving it.

Ciao
Enrico

minimus

unread,
Nov 21, 2011, 8:03:00 AM11/21/11
to
"Enrico Gregorio" wrote in message
news:211120111346587886%Facile.d...@in.rete.it...
Hello, Thank you for your reply. In the minimal example below, I replaced
"Age" with "HHH". The space above and below H are not same. So to me, the
HHH text is not vertically centered. First, we need to agree on this. Am I
mistaken or not? I included your solution. This is exactly what I would like
to have. And I am wondering why I cannot achieve this in my first approach
with \hlines. Why the text in not vertically centered using the \hlines?

(The rest of the table is not releveant because your solution is what I
want. So please forget about the rest of the table. It will only complicate
the matter for no reason)

\documentclass{article}
\usepackage{array}
\begin{document}


\begin{tabular}{ | m{2cm} | *{11}{m{0.5cm} | } }
\hline
HHH & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 & 71 & 72
\\
\hline
\end{tabular}


\setlength{\extrarowheight}{1.5pt}
\centering
\begin{tabular}{ | p{2cm} | *{11}{>{\centering\arraybackslash}p{0.5cm}| } }
\hline
HHH & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 & 71 & 72 \\
\hline
\end{tabular}


\end{document}

Lars Madsen

unread,
Nov 21, 2011, 8:26:01 AM11/21/11
to
My newsreader (Thunderbird) does not copy signatures, when replying to a
message.

But your reply is recognised as a signature.

Suggestion, wehn you delete my signature from your replay, also remove
the two '--' above it.

Ulrike Fischer

unread,
Nov 21, 2011, 12:16:41 PM11/21/11
to
Am Mon, 21 Nov 2011 14:03:00 +0100 schrieb minimus:

Could you please use a news or mail client which is able to get the
quoting right? And learn to quote? http://learn.to/quote/

Your postings are quite unreadable.


> Hello, Thank you for your reply. In the minimal example below, I replaced
> "Age" with "HHH". The space above and below H are not same.

At first you should define more exactly your reference points. What
is "the space above" the H? The space between the top of the H and
the line? Or the space from the base line to the top line?

--
Ulrike Fischer

minimus

unread,
Nov 21, 2011, 2:18:04 PM11/21/11
to
"Ulrike Fischer" wrote in message news:hf273phh...@nililand.de...
The space between "the line above H" and "H" is not the same as the space
between "the line below H" and "H".

Manuel Collado

unread,
Nov 21, 2011, 6:47:30 PM11/21/11
to
El 21/11/2011 20:18, minimus escribió:
> "Ulrike Fischer" wrote in message news:hf273phh...@nililand.de...
>
> Am Mon, 21 Nov 2011 14:03:00 +0100 schrieb minimus:
>
> Could you please use a news or mail client which is able to get the
> quoting right? And learn to quote? http://learn.to/quote/
>
> Your postings are quite unreadable.
>
>
>> Hello, Thank you for your reply. In the minimal example below, I replaced
>> "Age" with "HHH". The space above and below H are not same.
>
> At first you should define more exactly your reference points. What
> is "the space above" the H? The space between the top of the H and
> the line? Or the space from the base line to the top line?

One more time: *PLEASE* *LEARN* *TO* *QUOTE* when posting to usenet.

Please look at http://lml.ls.fi.upm.es/~mcollado/garbage.png to see how
your posts looks in my newsreader.

--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado

0 new messages