First, my apologies if this is a FAQ; and I'm not particularly
experienced or talented with TeX, so apologies if this is just a stupid
question, too.
I'm using LaTeX and PDFLaTeX from the TeTeX 1.0.7 distribution on a
Slackware 8.0 linux box.
I have created a table using the tabular environment, thusly:
\begin{tabular}{cccccc}
1&1&1/2&$\cdots$&2/4&1\\\hline
Flag&Address&Control&Information&Frame Check Sequence&Flag\\\hline
\end{tabular}
(It also happens to be sitting inside a figure environment and a center
environment, if that is relevant.)
I would like vertical lines separating the cells on the bottom row, but
not on the top row. There are many many copies on the web of a set
of documentation for LaTeX by Sheldon Green (1995), and the entry for
\vline states:
> The \vline command will draw a vertical line extending the full height
> and depth of its row. An \hfill command can be used to move the line
> to the edge of the column.
This sounds like exactly what I want, but changing the second row to:
\vline\hfill Flag&\vline\hfill Address& ...
... produces exactly the same output as:
\vline Flag&\vline Address& ...
... i.e. the vertical lines are there, but are not at the edge of their
respective columns (I have no idea how to measure distances, but they're
around the width of an upper case character too far to the right). I
get this result using both LaTeX and PDFLaTeX.
Does anyone have any idea why the \hfill doesn't move the vertical line?
I guess it's because I've misunderstood and placed the \hfill in the
wrong place.
Thanks for any help,
Alexandra
--
"Computers in the future may weigh no more than 1.5 tons."
Popular Mechanics, 1949
I think They recommend \centering as it does not insert extra space.
> I would like vertical lines separating the cells on the bottom row, but
> not on the top row.
Usually you put vertical lines in by specifying them in the call of
tabular. So, \begin{tabular}{|c|c|c|}. If you want some lines with a
different format you temporarily override it by using multicolumn. In
your case that means a lot of multicolumns.
You might also look at the booktabs package which tries to persuade you
not to use lines in tables at all.
--
Michael Dewey
Trent Institute for Health Services Research
mailto:Michae...@nottingham.ac.uk
http://www.nottingham.ac.uk/~mhzmd/home.html
> I have created a table using the tabular environment, thusly:
>
> \begin{tabular}{cccccc}
> 1&1&1/2&$\cdots$&2/4&1\\\hline
> Flag&Address&Control&Information&Frame Check Sequence&Flag\\\hline
> \end{tabular}
>
> I would like vertical lines separating the cells on the bottom row, but
> not on the top row. There are many many copies on the web of a set
> of documentation for LaTeX by Sheldon Green (1995), and the entry for
> \vline states:
1995 is rather old.
>
>> The \vline command will draw a vertical line extending the full height
>> and depth of its row. An \hfill command can be used to move the line
>> to the edge of the column.
>
> This sounds like exactly what I want, but changing the second row to:
>
> \vline\hfill Flag&\vline\hfill Address& ...
>
> ... produces exactly the same output as:
>
> \vline Flag&\vline Address& ...
\hfill fills up space that is there, but it doesn't produce some. But
as the cell with "flag" is the widest \hfill has no effect there.
Look what happens when "flag" isn't the widest entry:
\documentclass{article}
\begin{document}
\begin{tabular}{cc}
a larger text &1 \\
\vline\hfill Flag&\vline\hfill Address\\
\end{tabular}
\end{tabular}
Now \hfill has something to work on.
But I think you don't really want \vline. \vline sets the line *in* the
cell. I think you are searching a line *between* cells. That is not the
same. Try
\documentclass{article}
\begin{document}
\begin{tabular}{cc}
1&1 \\
\multicolumn{1}{|c|}{Flag}& \multicolumn{1}{c|}{Address}
\end{tabular}
\end{document}
Ulrike Fischer
I would specify the vertical lines for the tabular as a whole and then
use \multicolumn on the first row to override them.
A shorter example:
\begin{tabular}{|c|c|}
\multicolumn{1}{c}{1} & \multicolumn{1}{c}{2} \\ \hline
First & Second \\ \hline
\end{tabular}
Peter W.
> Alexandra Walford <cr...@subdimension.com> schrieb:
>
> > a set of documentation for LaTeX by Sheldon Green (1995), and the
>
> 1995 is rather old.
True, but it seems to be the predominant piece of reference material on
the 'net.
> \multicolumn{1}{|c|}{Flag}& \multicolumn{1}{c|}{Address}
Thank you Ulrike, Michael and Peter; I'd vaguely heard of \multicolumn
but had no idea that it could be used in such a way. Currently I'm
defining the columns with |c|c|c| and overriding the borders on the top
row, which is working perfectly.
i take it you mean http://www.giss.nasa.gov/latex/ ? (this is
google's first choice when i ask about it).
if you _do_ mean that, please remember that it's talking about an
10-year-old version of latex, that hasn't been supported since before
the document was written. as such, minor deviations from the way
latex _actually_ works are to be expected; however, i think the advice
about rules and fills that you got from it was wrong even for latex
2.09.
and as for it being the predominant on-line documentation ... i don't
recall it ever being recommended to anyone in this group (and i've
been reading the group since it was first created, long before 2.09
disappeared from the scene).
i suggest you acquire a copy of lshort (in the language of your
choice) and read that instead.
--
Robin Fairbairns, Cambridge -- the man with no voice (_again_)
> i take it you mean http://www.giss.nasa.gov/latex/ ? (this is google's
> first choice when i ask about it).
I do.
> if you _do_ mean that, please remember that it's talking about an
> 10-year-old version of latex, that hasn't been supported since before
> the document was written. as such, minor deviations from the way latex
> _actually_ works are to be expected; however, i think the advice about
> rules and fills that you got from it was wrong even for latex 2.09.
Fair enough and to be expected; I'm not particularly surprised to find
that certain details are in fact in error. Even so, I have the notion
that the basic concepts and commands are fairly similar, even 10 years
on, so I've been using that documentation as a general guide, and it's
usually quite helpful.
> and as for it being the predominant on-line documentation ... i don't
> recall it ever being recommended to anyone in this group (and i've
> been reading the group since it was first created, long before 2.09
> disappeared from the scene).
I am not a regular subscriber to this group; googling is my main source
of help and information with latex, and as you said, the documentation
in question is google's first result. In fact, when I searched for
help on \vline and \hfill, almost every single result was a mirror copy
of that documentation (I scanned through the entire list of results).
Therefore it seemed to me to be predominant (although, as it turns out,
predominant in quantity only and not quality). (And so, because I could
find nothing to confirm nor deny Green's assertions about \hfill and
\vline, I asked here, and received some very helpful responses. In
retrospect, I should have altered my search terms, but at the time I had
no idea of \multicolumn's relevance, nor of any other relevant search
terms. I'll know for next time.)
> i suggest you acquire a copy of lshort (in the language of your
> choice) and read that instead.
Will do, thank you. I haven't paid it too much heed in the past due to
its book-like format (such things don't sit that well with me), but you
seem to imply that it's the definitive reference, so I'll persevere :)
The hyperlinked pdf I just found definitely helps :)
Me too! I want a concise reference, not an introduction, long or short as
the case may be. I want to put my cursor on a keyword and click F1 and it
goes straight to help on that thing, plus useful related links. And the
nasa.gov article is the closest thing I've found to that so far.
--
Lucian Wischik, Queens' College, Cambridge CB3 9ET. www.wischik.com/lu