tufte cls: hyperref, PDFDocEncoding & floats

413 views
Skip to first unread message

osna

unread,
Nov 4, 2009, 6:54:43 AM11/4/09
to tufte-latex
Hello Kevin & other developers,

I'm using the tufte-handout.cls one and a half year, first with
TeXShop, then - most time - with LyX as editor and helpful cap.

The works I edit are linguistic ones, language teaching and presenting
old texts (in Westphalian-Saxon, sister of Middle English). Therefore
I'm glad, that tufte-latex cultivates and forster the use of (helping)
sidenotes! LyX on the other hand facilitate the use of IPA phonetical
characters which I need.

Not until the other week I finally established tufte-latex 3.0.0 with
the result that firstly my hitherto made documents couldn't be
processed (compiled) any more, not in TeXShop nor LyX.

I got LaTeX warnings and errors like:

! LaTeX Error: Command \cplabel already defined.
! LaTeX Error: Command \adjustwidth already defined.

Package hyperref Warning: Token not allowed in a PDF string
(PDFDocEncoding):
(hyperref) removing `\afterassignment' on input line
53.

<= this one 25 times with another "removing"-specification.

and even when there are more than ten sidenotes:

»! LaTeX Error: Too many unprocessed floats.«

Therefore I had a correspondence with the LyX developers. (Myself I am
not at all a programmer or LaTeX expert.) On this basis I ask you:

=>hyperref: Is it wise to load the hyperref pkg already with the .cls,
which does not allow or make much complicated to configure it in the
doc's preamble?

=>PDFDocEncoding (which is not Unicode!): is it wise to set this in
the .cls, isn't it a disregard of other languages than English for use
with tufte-latex? - The umlaute (mutated vowels) will not function in
pdf-bookmarks, unless the hyperref pkg is loaded with the "unicode"
option.

=> "Too many unprocessed floats" - I don't know why I had less cases
of the problem with tufte-handout-version-2. Anyway, it is not good in
a doc-class which cultivates and demand extended use of sidenotes.

For the latter I finally discovered already a work-arround (or
solution?) with \usepackage{morefloats} in the preamble...

So I concentrate here on asking a better solution for hyperref and -
above all - for the PDFDocEncoding, i. e. Unicode.

Do you think that you develope solutions for one or all the
inconveniences, snags and headaches mentioned above?
Have you other advice?

Regards
joachim
--
MacTeXLive 2008 - TeXShop 2.18-svn - LyX 1.6.4.1
MacBook Pro OSX 10.4.11 Tiger (intel)

Kevin Godby

unread,
Nov 4, 2009, 3:12:45 PM11/4/09
to tufte...@googlegroups.com
Hello, Joachim.

On Wed, Nov 4, 2009 at 5:54 AM, osna <osna...@googlemail.com> wrote:
>
> Hello Kevin & other developers,
>
> I'm using the tufte-handout.cls one and a half year, first with
> TeXShop, then - most time - with LyX as editor and helpful cap.
>
> The works I edit are linguistic ones, language teaching and presenting
> old  texts (in Westphalian-Saxon, sister of Middle English). Therefore
> I'm glad, that tufte-latex cultivates and forster the use of (helping)
> sidenotes! LyX on the other hand facilitate the use of IPA phonetical
> characters which I need.
>
> Not until the other week I finally established tufte-latex 3.0.0 with
> the result that firstly my hitherto made documents couldn't be
> processed (compiled) any more, not in TeXShop nor LyX.
>
> I got LaTeX warnings and errors like:
>
> ! LaTeX Error: Command \cplabel already defined.
> ! LaTeX Error: Command \adjustwidth already defined.

The Tufte-LaTeX document classes load the changepage (or chngpage)
package themselves. So if you attempt to load the package in the
preamble of your document, you will see these errors. Since we
require this package for the fullwidth environment and figure* floats,
the best solution is to remove \usepackage{changepage}% (or chngpage)
from the preamble of your document.

> Package hyperref Warning: Token not allowed in a PDF string
> (PDFDocEncoding):
> (hyperref)                removing `\afterassignment' on input line
> 53.
>
> <= this one 25 times with another "removing"-specification.

This is a warning emitted by the hyperref package when it is
converting LaTeX code into plain text. You can almost always safely
ignore these.

> and even when there are more than ten sidenotes:
>
> »! LaTeX Error: Too many unprocessed floats.«

You discovered a solution to this problem below. I'll add my comments there.

> Therefore I had a correspondence with the LyX developers. (Myself I am
> not at all a programmer or LaTeX expert.) On this basis I ask you:
>
> =>hyperref: Is it wise to load the hyperref pkg already with the .cls,
> which does not allow or make much complicated to configure it in the
> doc's preamble?

It's not particularly wise, no. I'm trying to work around the issue,
but have hit some snags and haven't had time to get back into it yet.

In the meantime, a workaround you can use is to provide the 'nohyper'
document class option:

\documentclass[nohyper]{tufte-book}

and then load hyperref in the preamble of your document with the
options you prefer. Some options can be set in the preamble with
\hypersetup, but not all of them.

> =>PDFDocEncoding (which is not Unicode!): is it wise to set this in
> the .cls, isn't it a disregard of other languages than English for use
> with tufte-latex? - The umlaute (mutated vowels) will not function in
> pdf-bookmarks, unless the hyperref pkg is loaded with the "unicode"
> option.

I don't think we're explicitly setting PDFDocEncoding in our code --
hyperref simply defaults to that when the unicode option isn't
specified. Are you aware of any caveats to using the unicode option?
At first glance, it seems like using unicode makes for a sensible
default. I'm happy with adding this option as a default if there are
no major issues with it.

> => "Too many unprocessed floats" - I don't know why I had less cases
> of the problem with tufte-handout-version-2. Anyway, it is not good in
> a doc-class which cultivates and demand extended use of sidenotes.
>
> For the latter I finally discovered already a work-arround (or
> solution?) with \usepackage{morefloats} in the preamble...

Using the morefloats package will get you a bit farther: it adds more
'slots' for sidenotes/floats.

The Tufte-LaTeX document classes automatically include the 'placeins'
package. This package provides the \FloatBarrier command. If you put
the \FloatBarrier command in your document, it will force LaTeX to
process all of the floats before typesetting any more material. (This
also has the side-effect of starting a new paragraph, so use it
between paragraphs.) I've attached a short example document that
illustrates the effect of the \FloatBarrier command (along with using
the morefloats package).

It looks like the morefloats package could go even further in what it
does. I'll look into the trade-off between memory usage and adding
more float 'slots'. It would definitely be nice for people using the
Tufte-LaTeX document classes to never have to see the 'too many
unprocessed floats' error.

> So I concentrate here on asking a better solution for hyperref and -
> above all - for the PDFDocEncoding, i. e. Unicode.
>
> Do you think that you develope solutions for one or all the
> inconveniences, snags and headaches mentioned above?
> Have you other advice?

For the hyperref/unicode issue, you can use the 'nohyper' workaround I
mentioned above. I'll look into the unicode option and will continue
to try to get hyperref to bend to my will. :-)

Let me know if have problems with any of the workarounds I mentioned
above or if you encounter further problems with the Tufte-LaTeX
document classes.

Thanks for your help in identifying these shortcomings!

--Kevin

handout-many-sidenotes.tex

Kevin Godby

unread,
Nov 4, 2009, 10:02:55 PM11/4/09
to Uwe Stöhr, tufte...@googlegroups.com, Kreimer-de Fries, Jue...@spitzmueller.org
Hello, Uwe et al.

On Wed, Nov 4, 2009 at 8:19 PM, Uwe Stöhr <uwes...@web.de> wrote:
> This doesn't work here. Whenh I compile the attached TeX file, I get 4 LaTeX
> errors. Two of them are about a missing \fi, so it might be a bug in the
> tufte class. (I'm using the latest version of tufte.)
>
> Besides this,  never get any PDF bookmark when using the tufte-handbook
> class, no matter if I use the "nohyper" option or not.

Are you using the latest released version or the version in svn?

When I compile this with the svn version, it compiles without error
(using both pdflatex and latex). Can you add 'debug' to the
documentclass options list and send me the resulting log file?

Thanks!

--Kevin

Kevin Godby

unread,
Nov 5, 2009, 9:09:25 PM11/5/09
to Uwe Stöhr, tufte...@googlegroups.com, Kreimer-de Fries, Jue...@spitzmueller.org
'allo.

On Thu, Nov 5, 2009 at 6:57 PM, Uwe Stöhr <uwes...@web.de> wrote:
> Kevin Godby schrieb:


>
>>> Besides this,  never get any PDF bookmark when using the tufte-handbook
>>> class, no matter if I use the "nohyper" option or not.
>>
>> Are you using the latest released version or the version in svn?
>

> I'm using version 3.0.0 of tufte.


>
>> When I compile this with the svn version, it compiles without error
>> (using both pdflatex and latex). Can you add 'debug' to the
>> documentclass options list and send me the resulting log file?
>

> It is attached.

Ah, it looks like the 'nohyper' option was added after 3.0.0 was
released. Sorry.

Try using the version in svn and see if it compiles successfully
there. If there are still bugs, please let me know and I'll try to
fix them.

http://code.google.com/p/tufte-latex/source/checkout

(I really do need to release a new version soon!)

Thanks!

--Kevin

Joachim

unread,
Nov 6, 2009, 7:39:34 AM11/6/09
to tufte...@googlegroups.com, Kevin Godby, Uwe Stöhr
Am 05.11.2009 um 04:02 schrieb Kevin Godby:
When I compile this with the svn version, it compiles without error
(using both pdflatex and latex).   Can you add 'debug' to the
documentclass options list and send me the resulting log file?

Hello Kevin,

I established the svn version of tufte-latex and run Uwes test file (hope I copied it right) into TeXShop, I added some umlaute & Co:

ä - ö - ü - ß

å - ç - Å - œ - æ

which were processed quite well, others, as »ɔ« not (but that had been clear, so I entered them again, with textipa).

It compiled well!


LyX crashed as I tried (only once) to import this file (might be I had made it wrong), so I reproduced it by hand in LyX, => it gives the correct result (even better, because LyX transformed the IPA - »ɔ« automatically).

I exported than the .lyx file to .tex and run it.

It compiled well! (Have the .log and .tex files attached, too.)

I can't give advice myself how to construct the tufte-handout and -book.cls (and common.def) at the best for world-wide users (loading hyperref in advance or better let this be made with the wanted options by the user (and the LyX layouter ;-). Think about it for the next release! I hopefully aspect the LyX developer to find a solution for the processing with LyX.

Goutgaun! (wellgone / all the best)
joachim
--
MacBook Pro OSX 10.4.11 Tiger - MacPorts 1.7
MacTeXLive 2008 - TeXShop 2.18-svn - TeXmakerX 1.8 svn - LyX 1.6.4
Browser: Safari & Opera 10.0 (auch als Newsreader)

The original .log and .tex files:

uwes-noindent-test.log
uwes-noindent-test.tex
uwes-test-lyxexpto.log
uwes-test-lyxexpto.tex

Kevin Godby

unread,
Nov 7, 2009, 3:25:46 PM11/7/09
to Uwe Stöhr, tufte...@googlegroups.com, Kreimer-de Fries
Greetings!

On Sat, Nov 7, 2009 at 1:10 PM, Uwe Stöhr <uwes...@web.de> wrote:
> Before doing this, can you please have a look at this bug:
> I checked out the latest tufte files and run the attached TeX-file. I get a
> bunch of errors, one for every \footnote and one for every \sidenote. I
> attached the logfile.
> Note that this errors didn't occur with tufte 3.0.0.

I'll try. When hyperref is loaded, it redefines the \footnote
commands and overrides the Tufte-LaTeX redefinition of \footnote.

In short, the hyperref package is a pain. :-) It needs to be loaded
*before* some code and *after* other code (and keeping it all straight
gives me a headache).

But I'll add this to the list of bugs and try to get the hyperref
stuff working before the next release.

Thanks for reporting the bug!

--Kevin

Kevin Godby

unread,
Nov 7, 2009, 4:03:57 PM11/7/09
to Uwe Stöhr, tufte...@googlegroups.com, Kreimer-de Fries
On Sat, Nov 7, 2009 at 2:46 PM, Uwe Stöhr <uwes...@web.de> wrote:
> Kevin Godby schrieb:

>
>> In short, the hyperref package is a pain.  :-)  It needs to be loaded
>> *before* some code and *after* other code (and keeping it all straight
>> gives me a headache).
>
> It's not that bad, we also support hyperref in LyX without big problems. I
> recommend to ask Heiko Oberdiek - the hyperref author - when you have
> problems. He always responds and is very helpful.

It looks like hyperref redefines the footnote code only if
hyperfootnotes=true (which is the default). Adding the
'hyperfootnotes=false' option when you load the hyperref package
should resolve the issue.

I've added \PassOptionsToPackage{hyperfootnotes=false}{hyperref} so
that it will work with the default options. This fix has been
committed to svn.

Thanks for your help!

--Kevin

Joachim

unread,
Nov 8, 2009, 9:45:00 AM11/8/09
to tufte...@googlegroups.com, Uwe Stöhr, Kevin Godby
Am 07.11.2009 um 22:03 schrieb Kevin Godby:

It looks like hyperref redefines the footnote code only if

hyperfootnotes=true (which is the default).  Adding the

'hyperfootnotes=false' option when you load the hyperref package

should resolve the issue.


I've added \PassOptionsToPackage{hyperfootnotes=false}{hyperref} so

that it will work with the default options.  This fix has been

committed to svn.


Hello, Kevin,

without this newest change I had the same errors as Uwe with his testfile (part of the normal sample-handout) with URL's in the citation (sidenote).

Running the file with your newest tufte-common.def (r129) and Uwe's testfile with the [nohyper] doc-class option and in the preamble:

\usepackage[unicode=true, pdfusetitle,
 bookmarks=true,bookmarksnumbered=true,bookmarksopen=true, bookmarksopenlevel=2, breaklinks=true,pdfborder={0 0 0}, backref=false,colorlinks=false]
 {hyperref}

it worked, in TeXShop and with LyX-LaTeX. Also I tested it with same real document of mine with success. In LaTeX (TeXShop) also the \hyperref{}{} worked, but not (yet) in LyX - I will asked this betimes there. So I have to use for the time being in LyX-LaTeX only the \url{} command for internet links.

Thank you for reacting to our lament!

Goutgaun! joachim

chip

unread,
Nov 9, 2009, 7:54:23 AM11/9/09
to tufte-latex

>
> > I've added \PassOptionsToPackage{hyperfootnotes=false}{hyperref} so
> > that it will work with the default options.  This fix has been
> > committed to svn.
>

hi
I have been watching the svn listing, but the dates don't reflect a
recent upload. Is this change for hyperref functionality a non-version
change to Tufte-LaTeX Release 3.0.0?
thanks,
Ray

Kevin Godby

unread,
Nov 9, 2009, 4:09:09 PM11/9/09
to tufte...@googlegroups.com
On Mon, Nov 9, 2009 at 6:54 AM, chip <br...@pa.msu.edu> wrote:
> I have been watching the svn listing, but the dates don't reflect a
> recent upload. Is this change for hyperref functionality a non-version
> change to Tufte-LaTeX Release 3.0.0?
> thanks,
> Ray

I don't usually change the date/version in the code until it's time
for a release. The hyperref change is in revision 129.

--Kevin

Joachim

unread,
Nov 14, 2009, 2:28:52 PM11/14/09
to tufte...@googlegroups.com, Kevin Godby, Uwe Stöhr
Am 11.11.2009 um 03:36 schrieb Uwe Stöhr:
I wrote:
Thanks for this fix, but it still doesn't compile. I get a hyperref error when there are cross-references to figure or figure*, see the attached testfile.

I also get this bug for references to tables but not for references to marginfigures.

No wonder: on my side neither, with Uwe's the test file…

Given that I first wrote (08.11.2009 - 15:45), only testing with success \url{}:
it worked, in TeXShop and with LyX-LaTeX. Also I tested it with same real document of mine with success. In LaTeX (TeXShop) also the \hyperref{}{} worked, but not (yet) in LyX - I will asked this betimes there. So I have to use for the time being in LyX-LaTeX only the \url{} command for internet links.

… I'm not the competent tester. So I let it to the talk between Uwe Stöhr and Kevin Godby, so last to Kevin, to find a  stable solution for the next release of tufte-latex.

But I would be very sorry, if my further use of the tufte-classes would be foredoomed, shipwrecked because of the loading of hyperref by the tufte-common.cls! 

The idea of the utilization of Tufte's layout and it's LaTeX realization is too important to be restricted to the use for English writing or it's character-set.

Goutgaun!
joachim

Kevin Godby

unread,
Nov 15, 2009, 2:49:47 AM11/15/09
to Uwe Stöhr, tufte...@googlegroups.com, Kreimer-de Fries
Hello, Uwe.

On Tue, Nov 10, 2009 at 8:24 PM, Uwe Stöhr <uwes...@web.de> wrote:
> Thanks for this fix, but it still doesn't compile. I get a hyperref error
> when there are cross-references to figure or figure*, see the attached
> testfile.

> I expected that hyperref was turned-off completely or better not even loaded
> when the nohyper option is used.

I just committed a patch that should fix this (r130). Could you
verify that this resolves the bug?

What happened is that we store a copy of the definitions of \caption
and \label during \AtBeginDocument. When hyperref is loaded, it
redefines these commands. Unfortunately, it redefines the commands
after we've stored a copy of the definitions -- so we end up storing
the original LaTeX definitions instead of the new hyperref
definitions.

To fix this, I've started storing the definitions of \caption and
\label when you create the figure or table. This way, we'll always
have the latest (current) definition.

(We save copies of the \caption and \label definitions, because we
replace those commands with our own that gather the parameters to be
put in a box alongside the figure/table contents. After we're done
typesetting the caption alongside the figure/table, we restore the
original definitions.)

If you continue to encounter problems, please let me know.

Thanks!

--Kevin

Kevin Godby

unread,
Nov 15, 2009, 2:52:10 AM11/15/09
to Joachim, tufte...@googlegroups.com, Uwe Stöhr
Hello, Joachim.

I just uploaded a patch that I believe fixes the \ref problem that Uwe
discovered. If you have any other problems with the Tufte-LaTeX
document classes, please let me know.

Thanks!

--Kevin

Kevin Godby

unread,
Nov 15, 2009, 5:21:44 PM11/15/09
to Uwe Stöhr, tufte...@googlegroups.com, Kreimer-de Fries
On Sun, Nov 15, 2009 at 2:22 PM, Uwe Stöhr <uwes...@web.de> wrote:
> This solves the bug but introduces a new bug and the nohyper option still
> doesn't disable hyperref:
>
> - Take the attached testfile. I've used the nohyper option and then load
> hyperref with the option to have bookmarks, but only get bookmarks for
> chapters, but not for the sections.
>
> What we need for LyX is a way to turn off hyperref _completely_ in the tufte
> classes, so that the user can load hyperref with their customized settings.

This is the expected behavior. According to the hyperref docs:

The depth of the outlines is controlled by option bookmarksdepth. The
option acts globally and distinguishes three cases:
* bookmarksdepth: Without value hyperref uses counter tocdepth
(compatible behaviour and default).
* bookmarksdepth=<number>: the depth is set to <number>.
* bookmarksdepth=<name>: The <name> must not start with a number or
minus sign. It is a document division name (part, chapter, section,
...). Internally the value of macro \toclevel@<name> is used.

The book class sets the tocdepth so that only chapters are shown in
the table of contents by default.

> The new bug is:
>
> - Take the attached LyX file. You find there in section "Figures" a figure
> float followed by a MarginFigure float. In the PDF output the caption of
> both floats overlap each other making it unreadable.

Yes, this is a known issue. I would like to come up with a way to
automatically avoid these overlap conditions, but I'm not sure how to
do that yet.

--Kevin

Reply all
Reply to author
Forward
0 new messages