Tufte-LaTeX / tufte-latex

A Tufte-inspired LaTeX class for producing handouts, papers, and books
https://tufte-latex.github.io/tufte-latex/
1.68k stars 300 forks source link

XeTeX breaks headers in Tufte-handout #107

Open chreliot opened 8 years ago

chreliot commented 8 years ago

When using Tufte-Handout class with fontspec (and therefore XeTeX), I get messed-up running headers on pages 2 and following . The headers repeat the Title and then add a black box.

i1gf5

A lot of errors are thrown up, starting with:

Latex Error: ./MinimalExample.tex:13 Argument of \MakeTextLowercase has an extra }.
Runaway argument?

A minimal document producing this error follows:

\documentclass[nofonts]{tufte-handout}
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Adobe Caslon Pro}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Helvetica}
\setmonofont[Scale=MatchLowercase]{Inconsolata}
\usepackage{lipsum}
\title{Problem Document Title}
\author{Author Name}
\date{\today}
\begin{document}
\maketitle
\lipsum[1-10]
\end{document}  

This issue and an effective fix for it are previously documented at http://tex.stackexchange.com/questions/200722/xetex-seems-to-break-headers-in-tufte-handout

tex.stackexchange.com user egreg offered the following diagnosis: “In tufte-common.def it is said that in case XeLaTeX is used, its features for letter spacing will be used, but the authors forgot to do it, so the soul fallback mechanism is used, which miserably fails.”

I am not sure whether the developers have seen this issue yet, but as I'm pleased to see that the tufte classes are continuing to be developed, I want to flag it. Thanks for your great work!

copperx commented 8 years ago

It appears that this is the same problem I reported in #105, which I found when a enumeration spans two pages.

fgrosshans commented 8 years ago

I’ve had the same problem with LuaLaTeX. A slightly simpler minimal file producing creating the bug is :

\usepackage{lipsum}
\title{Lorem Ipsum} 
\begin{document} 
\maketitle 
\lipsum[1-5] \end{document}

Slightly dapting egreg’s fix from tex.sx pointed to by @chreliot above so that it works for both LuaLaTex and XeLaTeX gives :

\usepackage{lipsum, ifluatex, ifxetex}
%Next block avoids bug, from  http://tex.stackexchange.com/a/200725/1913 
\ifx\ifxetex\ifluatex\else % if lua- or xelatex http://tex.stackexchange.com/a/140164/1913
  \newcommand{\textls}[2][5]{%
    \begingroup\addfontfeatures{LetterSpace=#1}#2\endgroup
  }
  \renewcommand{\allcapsspacing}[1]{\textls[15]{#1}}
  \renewcommand{\smallcapsspacing}[1]{\textls[10]{#1}}
  \renewcommand{\allcaps}[1]{\textls[15]{\MakeTextUppercase{#1}}}
  \renewcommand{\smallcaps}[1]{\smallcapsspacing{\scshape\MakeTextLowercase{#1}}}
  \renewcommand{\textsc}[1]{\smallcapsspacing{\textsmallcaps{#1}}}
\fi

\title{Lorem Ipsum} 
\begin{document} 
\maketitle 
\lipsum[1-5] 
\end{document}
fgrosshans commented 8 years ago

It is a duplicate of issue #64

japorized commented 5 years ago

Apparently, installing microtype solved this problem for me.

(Sorry if I should not touch old issues)

fgrosshans commented 5 years ago

Apparently, installing microtype solved this problem for me.

How ? The following file stills shows the problem with me :

\documentclass{tufte-handout}
\usepackage{microtype}
\usepackage{lipsum}
\title{Lorem Ipsum} 
\begin{document} 
\maketitle 
\lipsum[1-5]
\end{document}
japorized commented 5 years ago

Your MWE worked on my end. Also you should not need to explicitly call for microtype as that should be handled by the documentclass.

From line 650 of tufte-common.def

%%
% Improved letterspacing of small caps and all-caps text.
%
% First, try to use the `microtype' package, if it's available. 
% Failing that, try to use the `soul' package, if it's available.
% Failing that, well, I give up.

Just to make sure: do you have soul installed as well? It should serve as a fallback at certain parts of the code.

fgrosshans commented 5 years ago

I have both microtype and soul installed, ad everything works fine with pdflatex, but nothing works with xelatex or lualatex without the workaround given in my post from 2016-02-16 above.

I have checked tufte-common.def, and the line with the relevant logic seem to be the lines 739 – 773, which are commented out, including the following line 744

        %% TODO use xetex letterspacing
japorized commented 5 years ago

Ah, my bad for forgetting that this is about xetex. And I just saw that you also commented on a similar issue and noticed the maintainer's replies. Sorry that I wasn't of any help.