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

header line across two columns

73 views
Skip to first unread message

cmdl...@gmail.com

unread,
Jun 19, 2016, 5:22:38 PM6/19/16
to
Hi, I'm using fancyhdr with a custom ornamental header line (using symbols from the fourier-orns package). In some sections in my document, I need to switch to two columns. The problem is that the header line doesn't extend all the way across the page as it does in single column mode. It only extends across the first column.

Here's an example:

-------------------------------------------------------------------------
\documentclass[letter,10pt]{article}
\usepackage[english]{babel}
\let\footruleskip\undefined
\usepackage{fancyhdr}
\usepackage{multicol}
\usepackage{fourier-orns}
\usepackage{lipsum}

\pagestyle{fancy}

\fancyhf{}

%Header line defined here.
\def\headrule{{\hrulefill \raisebox{-2.1pt}[10pt][10pt]{~~~\decofourleft\decotwo\decofourright~~~} \hrulefill}}

\pagestyle{fancy}

\begin{document}

\section{First Section}
\lipsum[1-4]

\newpage
\section{Second Section}
\begin{multicols*}{2}
\lipsum[1-4]
\end{multicols*}

\section{Third Section}
\lipsum[1-4]

\end{document}
-------------------------------------------------------------------------

For section 1 and 3, which are single columns, the header line is drawn across the page, whereas for section 2, which has two columns, it's only in the first column. How can I get the line to be the same as for the other sections?

Thanks.


Herb Schulz

unread,
Jun 19, 2016, 7:11:58 PM6/19/16
to
On Jun 19, 2016, cmdl...@gmail.com wrote
(in article<8428ce70-81e9-4229...@googlegroups.com>):
Howdy,

I know that if I use multicol, which balances the columns, rather than
multicol* there is no problem with your example. I also have to add a
\newpage to force the third section to the next page.

Don't know if that helps.

Good Luck,
Herb Schulz


cmdl...@gmail.com

unread,
Jun 20, 2016, 12:53:36 AM6/20/16
to
Thanks, Herb! Yes, that helps a lot. Although I don't really want balanced columns, I think I can live with it if it'll allow the header line to be drawn correctly.

jon

unread,
Jun 20, 2016, 5:58:36 PM6/20/16
to
i'd suggest two things:

1. load multicol after setting your page style;
2. do not use tildes (viz, ~~~) in your definition -- as your file shows,
you'll get bad spacing.

i'd do something like this:

\documentclass[letter,10pt]{article}
\usepackage[english]{babel}
\let\footruleskip\undefined
\usepackage{fancyhdr}
\usepackage{fourier-orns}
\usepackage{lipsum}

\pagestyle{fancy}
\fancyhf{}

\newlength{\decohdr}
\newlength{\rulehdr}
\settowidth{\decohdr}{\decofourleft\decotwo\decofourright}
\setlength{\rulehdr}{\dimexpr 0.5\textwidth - 0.5\decohdr - 6px \relax}

%Header line defined here.
\def\headrule{{%
\rule[0.5ex]{\the\rulehdr}{0.4pt}%
\hspace*{6px}%
\decofourleft\decotwo\decofourright
\hspace*{6px}%
\rule[0.5ex]{\the\rulehdr}{0.4pt}%
}}

\pagestyle{fancy}

\usepackage{multicol}

\begin{document}

\section{First Section}
\lipsum[1-4]

\newpage
\section{Second Section}
\begin{multicols*}{2}
\lipsum[1-4]
\end{multicols*}

\section{Third Section}
\lipsum[1-4]

\end{document}


cheers,
jon.

cmdl...@gmail.com

unread,
Jun 21, 2016, 3:16:18 AM6/21/16
to
Hi Jon,

Thank you very much! I think that's the fix, and I can keep the columns unbalanced. I don't understand why the original definition of the header doesn't work correctly, though?

jon

unread,
Jun 21, 2016, 11:46:36 AM6/21/16
to
On Tuesday, 21 June 2016 03:16:18 UTC-4, cmdl...@gmail.com wrote:
> Hi Jon,
>
> Thank you very much! I think that's the fix, and I can keep the columns unbalanced. I don't understand why the original definition of the header doesn't work correctly, though?

it's arguably a bug since neither package mentions the loading order as a
feature. presumably multicol does some redefining that 'confuses' fancyhdr.

however, it is a good policy (in my opinion) to impose some logic on
package loading. i tend to put things like font encoding and fonts, page
layout stuff, and language loading near the top, then packages that deal
with things like tables, lists, multicolumn, or parallel text things in
the middle. some packages, like hyperref, should go at or near the very end.
then i follow it with my own macros at the end of the preamble.

cheers,
jon.

Piet van Oostrum

unread,
Aug 28, 2016, 12:40:31 PM8/28/16
to
cmdl...@gmail.com writes:

> Hi, I'm using fancyhdr with a custom ornamental header line (using
> symbols from the fourier-orns package). In some sections in my document,
> I need to switch to two columns. The problem is that the header line
> doesn't extend all the way across the page as it does in single column
> mode. It only extends across the first column.
>
> Here's an example:

Hello,

I have not been following comp.text.tex for a long time. I recently
picked it up again, and I stumbled upon this problem. So forgive me to
come in very late in this discussion. I have started working again on
fancyhdr the last weeks after a long time of doing nothing. So now I
investigated what your problem is. I excerpt from your document:

> %Header line defined here.
> \def\headrule{{\hrulefill \raisebox{-2.1pt}[10pt][10pt]{~~~\decofourleft\decotwo\decofourright~~~} \hrulefill}}

The problem here is that you do not give the width of the headrule. In
the standard definition of fancyhdr the rule is set inside a box of
width \headwidth. In TeX if you put some 'horizontal' material in your
document (what this is) the default width is defined by \hsize. Now in
LaTeX this usually is equal to the \textwidth of the document, but in
multicol it is smaller (slightly less than half that) because it has to
typeset the text to that width.

So if the headers/footers are typeset while multicol is active, your
header will be typeset with the width of the multicol column.

A solution (apart from the solution Jon had given) is to put the whole
thing is a box of width \headwidth, like \makebox[\headwidth]{...},
together with replacing the ~~~ with a \hspace.

I will prepare an update of fancyhdr where I will set \hsize to
\headwidth during the processing of the headers/footers, but as I just
submitted a new version I will wait a few weeks with that.
--
Piet van Oostrum <pie...@pietvanoostrum.com>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
0 new messages