Headers/Footers + Spacing

987 views
Skip to first unread message

Ben Halpern

unread,
Oct 30, 2013, 3:12:49 PM10/30/13
to tufte...@googlegroups.com
Hello,

Really love the Tufte LaTeX class. I'm teaching myself LaTeX in order to use it.

It took me a little but I have almost produced a document in this class. I get like 40 errors and 2 bad boxes when I compile but it looks fine on the PDF. I haven't put in the figures and boxes that I'm going to so that might destroy everything but I'm working on these problems first

I'm using MikTex, TeXnicCenter and compiling with XeLatex -> PDF. 
TeXnicCenter I found recommended online and I liked the name XeLatex so that's why I use those, if there's a better method happy to hear.

I'm using Tufte-Book with [nols, nofont, oneside] because if I don't things go crazy. Although I'm using the book class what I'm producing is more of a report. Before I tried to port it to Tufte-Book I coded it all in the report class for practice.

So my three issues are:

1.) I'd like to make the white space above the chapters smaller. 

2.) I want to customize the Headers and Footers. The code I used in my Book class (I think that was it) to do this is:

%% Headers and footers
\newcommand{\changefont}{%
    \fontsize{7}{9.5}\selectfont
}
\usepackage{fancyhdr}
\fancypagestyle{plain}{
\fancyhead[LO,LE]{\changefont Author}
\fancyhead[RO,RE]{\changefont \thepage}
\fancyfoot[CO,CE]{\changefont Confidential}
\fancyfoot[LO,LE]{\includegraphics[width=1cm]{Logo}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\pagestyle{plain}

This gives me headers and footers on every page except the title, and the graphic. 

But when I input that in the preamble I get 58 of errors. 

In response I tried to edit it straight on the .cls file, first by %%commenting out all the stuff about headers that I found in the .cls (which had no effect) and then editing the stuff about headers in the .cls (also no effect)

Any help would be great! As I said, huge fan.

Kevin Godby

unread,
Oct 31, 2013, 2:16:04 AM10/31/13
to tufte-latex
Hello, Ben.

On Wed, Oct 30, 2013 at 2:12 PM, Ben Halpern <tien...@gmail.com> wrote:
> Really love the Tufte LaTeX class. I'm teaching myself LaTeX in order to use
> it.

Thanks for the kind words.

> I'm using Tufte-Book with [nols, nofont, oneside] because if I don't things
> go crazy. Although I'm using the book class what I'm producing is more of a
> report. Before I tried to port it to Tufte-Book I coded it all in the report
> class for practice.

Hopefully things aren't going too crazy. If you describe the problems
you're having and attach a .log file, I'd be happy to take a look.

> So my three issues are:
>
> 1.) I'd like to make the white space above the chapters smaller.

The Tufte-LaTeX document classes make use of the titlesec package for
formatting the headings. You can adjust the spacing above the chapter
heading by modifying the second parameter (50pt) to a be a smaller
amount:

\titlespacing*{\chapter}{0pt}{50pt}{40pt}

> 2.) I want to customize the Headers and Footers. The code I used in my Book
> class (I think that was it) to do this is:
>
> %% Headers and footers
> \newcommand{\changefont}{%
> \fontsize{7}{9.5}\selectfont
> }
> \usepackage{fancyhdr}
> \fancypagestyle{plain}{
> \fancyhead[LO,LE]{\changefont Author}
> \fancyhead[RO,RE]{\changefont \thepage}
> \fancyfoot[CO,CE]{\changefont Confidential}
> \fancyfoot[LO,LE]{\includegraphics[width=1cm]{Logo}}
> \renewcommand{\headrulewidth}{0pt}
> \renewcommand{\footrulewidth}{0pt}
> }
> \pagestyle{plain}
>
> This gives me headers and footers on every page except the title, and the
> graphic.

We use the fancyhdr package to format the running heads and feet
already, so you don't need to \usepackage{fancyhdr} (as we already
load it).

We use the 'fancy' page style for most pages in the book. The 'plain'
style is used for the first page of a new chapter. We use the 'empty'
page style for the title page and \cleardoublepage.

If you want your running heads and feet to work for all the page
styles, you'll need to set them individually. But it should work.

> In response I tried to edit it straight on the .cls file, first by
> %%commenting out all the stuff about headers that I found in the .cls (which
> had no effect) and then editing the stuff about headers in the .cls (also no
> effect)

You should be able to add the above code to the preamble of your
document (the part between \documentclass and \begin{document}). For
these changes, you shouldn't need to modify the Tufte-LaTeX files
directly.

Please let me know if these changes work as you want or if you
continue to encounter problems.

Thanks!

—Kevin Godby

Ben Halpern

unread,
Oct 31, 2013, 1:38:32 PM10/31/13
to tufte...@googlegroups.com
Kevin,

Thanks for the quick reply!

I'm not exactly sure what happened but I think I've moved backwards.

First I included the header/footer code I listed above, sans the \usepackage, and switched it to \fancypagestyle{fancy}, removing \pagestyle{plain}

This had the effect of giving me the headers and footers I wanted on content pages and the Tufte default headers and footers (\plaintitle and \thepage) on chapter pages.

Then when I switched it to \fancypagestyle{plain} and added \pagestyle{plain} back in it was the reverse, my head/feet on chapter pages, the default on content.

So then I tried to put both in at the same time.

At this point things got weird. First I wasn't able to save my project in TeXnicCenter anymore so I restarted my laptop and now, even when I only have one of the headers/footer codes in (which worked before everything went to shit), the compiler freezes and then I am unable to save again. 

If I restart TeXnicCenter I am able to save and compile as long as I comment out/delete the header and footer but if I do things freeze up again.

The only change I made (I think) was that I also had to move the graphics preamble above the header/footer preamble because otherwise it did not compile properly, I figured because it didn't know the path.

Below is a photo of the frozen compiler. This is where it freezes every time it has frozen.


Thanks again for your assistance. 

Ben Halpern

unread,
Oct 31, 2013, 2:46:19 PM10/31/13
to tufte...@googlegroups.com
Update:

Played around a little more.

It looks like my big problem is fancypagestyle{fancy}{lorem ipsum}

This does not freeze the compile:

\fancyhf{}
\fancypagestyle{plain}{
\fancyhead[LO,LE]{test}}
\pagestyle{plain}

It works and displays "test" on all of the pages that have chapter titles on it and not on content pages.

If I use this code


\fancyhf{}
\fancypagestyle{fancy}{
\fancyhead[LO,LE]{test}}

the compiler freezes like in the screencap above.

If I append \pagestyle{fancy} on that code it freezes at a different point.

Ben Halpern

unread,
Oct 31, 2013, 3:04:22 PM10/31/13
to tufte...@googlegroups.com
Update Update:

Sorry for flooding this thread.

I'd say all you need to read is this one.

I'm using the following code:

 %% Headers and footers 
 \newcommand{\changefont}{% 
     \fontsize{7}{9.5}\selectfont 
 } 
 
 \fancypagestyle{plain}{ 
 \fancyhead[LO,LE]{\changefont Author} 
 \fancyhead[RO,RE]{\changefont \thepage} 
 \fancyfoot[CO,CE]{\changefont Test} 
 \fancyfoot[LO,LE]{\includegraphics[width=1.5cm]{logo}} 
 \renewcommand{\headrulewidth}{0pt} 
 \renewcommand{\footrulewidth}{0pt} 
 } 
 \pagestyle{plain} 


and putting \pagestyle{plain} throughout my document.

This has succeeded in putting my headers and footers everywhere!
except

The second page of my TOC. I think I can understand why this is happening - the pagestyle{plain} is getting overwritten by the formatting switch that happens on the second page of the TOC, which I don't have access to in my main .tex file because it's happening behind the scenes in the .def or .cls.

Any recommendations? I've been trying to look through the .def to find where the command for \renewcommand{\tableofcontents}{ is but haven't located yet.

Kevin Godby

unread,
Nov 1, 2013, 8:22:01 PM11/1/13
to tufte-latex
Hi, Ben.

If you use \frontmatter or \mainmatter in your document and don't like
the default running heads style, you'll need to either redefine those
commands or reset the running head style after using them.

Here are the current definitions:

\renewcommand\frontmatter{%
\cleardoublepage%
\@mainmatterfalse%
\pagenumbering{arabic}%
%\pagestyle{plain}%
\fancyhf{}%
\ifthenelse{\boolean{@tufte@twoside}}%
{\fancyhead[LE,RO]{\thepage}}%
{\fancyhead[RE,RO]{\thepage}}%
}

\renewcommand\mainmatter{%
\cleardoublepage%
\@mainmattertrue%
\fancyhf{}%
\ifthenelse{\boolean{@tufte@twoside}}%
{% two-side
\renewcommand{\chaptermark}[1]{\markboth{##1}{}}%
\fancyhead[LE]{\thepage\quad\smallcaps{\newlinetospace{\plaintitle}}}%
book title
\fancyhead[RO]{\smallcaps{\newlinetospace{\leftmark}}\quad\thepage}%
chapter title
}%
{% one-side
\fancyhead[RE,RO]{\smallcaps{\newlinetospace{\plaintitle}}\quad\thepage}%
book title
}%
}

—Kevin

Ben Halpern

unread,
Nov 4, 2013, 5:24:46 PM11/4/13
to tufte...@googlegroups.com
Kevin,

Cool but I don't think I'm understanding how to renew commands properly.

Now that I have it so that every page other than the second page of the table of contents headed properly with \pagestyleplain I figured my problem was that the second page of the TOC wasn't getting switched to pagestyle plain. So I figured I could put this:

\renewcommand\frontmatter{% 
  \cleardoublepage% 
  \@mainmatterfalse% 
  \pagenumbering{arabic}% 
  \pagestyle{plain}% 


After \begindocument and it would fix this simple problem by making all front matter pages plain.

However I think I must be missing some core characteristic of the way LaTeX handles these sort of things because when I do that everything looks exactly the same. 

I've also tried to hardcode the headings I use for everything else within the else brackets of the boolean part of \renewcommand\frontmatter to no avail.

I've been trying to google around for solutions as well but it seems that everyone is able to fix things simply with the \fancypagestyle{plain} thing. This works for me everywhere but on this second page of the TOC.

-Ben
Reply all
Reply to author
Forward
0 new messages