Article View: comp.text.tex
Article #882Re: Custom headers in latex
From: Capt.J.T. Kirk
Date: Thu, 09 Apr 1992 10:10
Date: Thu, 09 Apr 1992 10:10
64 lines
2955 bytes
2955 bytes
In article <1992Apr9.004718.11370@uwm.edu>, andrew@csd4.csd.uwm.edu
(Andy Biewer) writes:
> I'm stymied. What I'm trying to do is get latex to put a custom header in
> my document modelled as follows:
>
> TOPIC P
> ---------------------------------------------------------------------------
>
> Where `TOPIC' is the current document section (which can be changed by
> changing the value of a new variable, say, \headtopic), `P' is the
> current page number, and the line goes from the left margin to the right
> margin. Of course, I'd like to get it to do twosided printing, so for even
> pages, things would be switched, or vice-versa. I've tried the \markboth
> command with \pagestyle{myheadings}, but cannot figure it out.
> .....
Yes, there is:
use between \documentstyle[ ]{} and \begin{document} this:
\makeatletter
\def\ps@myheadings{\let\@mkboth\markboth
\def\@oddfoot{}\def\@evenfoot{}
\def\@evenhead{\protect\underline{
\hbox \to\hsize{\thepage\hfil \leftmark}}}
\def\@oddhead{\protect\underline{
\hbox to\hsize{\rightmark\hfil \thepage}}}
\def\chaptermark##1{\markboth{\ifnum \c@secnumdepth>\m@ne
\thechapter. \ \fi ##1}{}}
\def\sectionmark##1{\markright{\ifnum \c@secnumdepth >\z@
\thesection \ \fi ##1}}}
\makeatother
%
\pagestyle{myheadings}
%----------------------------------
I have just recently tried this out and works fine. I haven't found out yet,
how you can change the TOPIC by a variable \headtopic (for example).
I`d say with \markright{TOPIC} it should work (I haven't tried it out so far).
If you want to play around a bit, you can use different fontstyles.
Just put a \it, or \sc, or whatever in the definition of
\@oddhead and \@evenhead.
You can also center the TOPIC by putting another \hfil after \leftmark in the
def. of \@evenhead, and another \hfil before \rightmark in the def. of
\@oddhead.
If you want to use this stuff in a style file, you don`t need the \makeatletter
and \makeatother commands.
BTW., sometimes, and sometimes not, LaTeX makes the \underline 3.65 pt too
wide. Any idea why?
Hope that helps.
Alexander <minidis@urz.unibas.ch>
----------------------------------------------------------------
-- Scotty, beam me up, there`s no intelligent life down here! --
-- (Capt. J.T. Kirk, USS Enterprise) --
----------------------------------------------------------------
Technical Details
Message-ID:
<1992Apr9.111023.14113@urz.unibas.ch>Path:
arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!darwin.sura.net!Sirius.dfn.de!chx400!urz.unibas.ch!minidisReferences:
<1992Apr9.004718.11370@uwm.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!darwin.sura.net!Sirius.dfn.de!chx400!urz.unibas.ch!minidis From: minidis@urz.unibas.ch ( Capt.J.T. Kirk ) Newsgroups: comp.text.tex Subject: Re: Custom headers in latex Message-ID: <1992Apr9.111023.14113@urz.unibas.ch> Date: 9 Apr 92 11:10:23 MET References: <1992Apr9.004718.11370@uwm.edu> Distribution: usa Organization: University of Basel, Switzerland Lines: 64