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

hyperref breaks geometry

146 views
Skip to first unread message

Oliver Corff

unread,
Sep 4, 2012, 2:28:23 PM9/4/12
to
Dear All,

I compile a text as a pdf for my ebook reader, with typical 6inch
e-ink screen --- and all of a sudden the paper size is way of the
expected measures whereas the textblock is now squeezed in the upper
left corner. Couldn't think of what mistake is in my setup until I
remembered that the last package added was hyperref. Though I could
not at all imagine that hyperref should in any conceivable manner
interfere with geometry as these two areas seem to have so little
in common, I tried to construct a minimal working example, and here
it is. Just play with the \usepackage{hyperref} line and look at the
resulting pdf.

My system: TL2012, installed just a few days after it became available.

Here my mwe:


\documentclass[oneside]{memoir}
\usepackage[driver=xetex,papersize={91mm,115mm},scale=0.98]{geometry}
\newif\ifebook\ebooktrue
\ifebook\usepackage[xetex]{hyperref}\fi% comment and uncomment this line!
\begin{document}
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
\end{document}

Any idea what could cause the problems?

Best regards,
Oliver.

--
Dr. Oliver Corff e-mail: co...@zedat.fu-berlin.de

Enrico Gregorio

unread,
Sep 4, 2012, 3:53:23 PM9/4/12
to
Load geometry after hyperref:

\documentclass[oneside]{memoir}
\newif\ifebook\ebooktrue
\ifebook\usepackage{hyperref}\fi% comment and uncomment this line!
\usepackage[papersize={91mm,115mm},scale=0.98]{geometry}
\begin{document}
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
Lots of meaningless text.
\end{document}

Specifying the driver is not needed for both hyperref and geometry.
You should try also with the specific methods provided by memoir,
\setstocksize and so on.

Ciao
Enrico

Oliver Corff

unread,
Sep 4, 2012, 10:42:57 PM9/4/12
to
Enrico Gregorio <Facile.d...@in.rete.it> wrote:
: Oliver Corff <co...@zedat.fu-berlin.de> wrote:

: > Any idea what could cause the problems?

: Load geometry after hyperref:

: \documentclass[oneside]{memoir}
: \newif\ifebook\ebooktrue
: \ifebook\usepackage{hyperref}\fi% comment and uncomment this line!
: \usepackage[papersize={91mm,115mm},scale=0.98]{geometry}
: \begin{document}
: Lots of meaningless text.
: Lots of meaningless text.
: \end{document}

: Specifying the driver is not needed for both hyperref and geometry.
: You should try also with the specific methods provided by memoir,
: \setstocksize and so on.

Hi Enrico,

Well, I believed in the warning issued in the hyperref documentation:

"Make sure it comes last of your loaded packages, to give it a
fighting chance of not being over-written, since its job is to
redefine many L TEX commands."

Besides, I couldn't even imagine how setting up hyperlinks should
interfere with geometry, text sizes etc.

And during my various experiments I thought specifying the driver
could be a probable resolve.

But you're right, sticking with \setstocksize and friends seems to
be the better solution.

Thanks,

Heiko Oberdiek

unread,
Sep 5, 2012, 2:16:45 AM9/5/12
to
Oliver Corff <co...@zedat.fu-berlin.de> wrote:

> I compile a text as a pdf for my ebook reader, with typical 6inch
> e-ink screen --- and all of a sudden the paper size is way of the
> expected measures whereas the textblock is now squeezed in the upper
> left corner. Couldn't think of what mistake is in my setup until I
> remembered that the last package added was hyperref. Though I could
> not at all imagine that hyperref should in any conceivable manner
> interfere with geometry as these two areas seem to have so little
> in common,

All, memoir, geometry and hyperref, are setting the media box.

> I tried to construct a minimal working example, and here
> it is. Just play with the \usepackage{hyperref} line and look at the
> resulting pdf.

> \documentclass[oneside]{memoir}
> \usepackage[driver=xetex,papersize={91mm,115mm},scale=0.98]{geometry}
> \newif\ifebook\ebooktrue
> \ifebook\usepackage[xetex]{hyperref}\fi% comment and uncomment this line!
> \begin{document}
> Lots of meaningless text.
> Lots of meaningless text.
> Lots of meaningless text.
> Lots of meaningless text.
> Lots of meaningless text.
> Lots of meaningless text.
> Lots of meaningless text.
> Lots of meaningless text.
> Lots of meaningless text.
> Lots of meaningless text.
> Lots of meaningless text.
> \end{document}

The behaviour of hyperref is correct. It sets the media box to
\stockwidth and \stockheight that have priority over \paperwidth and
\paperheight in class memoir. Package geometry does not support
\stockwidth and \stockheight.

I do not see the point in using geometry here, because memoir has its
own paper setting methods. In case of hyperref you can disable the
media box setting by option `setpagesize=false` or correct \stockwidth
and \stockheight:

\usepackage[...]{geometry}
\setlength{\stockwidth}{\paperwidth}
\setlength{\stockheight}{\paperheight}

--
Heiko Oberdiek

Oliver Corff

unread,
Sep 5, 2012, 3:56:55 AM9/5/12
to
Heiko Oberdiek <heiko.o...@googlemail.com> wrote:
: Oliver Corff <co...@zedat.fu-berlin.de> wrote:

: > Though I could
: > not at all imagine that hyperref should in any conceivable manner
: > interfere with geometry as these two areas seem to have so little
: > in common,

: All, memoir, geometry and hyperref, are setting the media box.

which I did not know. What is the purpose of hyperref to set the
media box?

: The behaviour of hyperref is correct. It sets the media box to
: \stockwidth and \stockheight that have priority over \paperwidth and
: \paperheight in class memoir. Package geometry does not support
: \stockwidth and \stockheight.

To which purpose? Naively, I thought hyperref creates a link structure.

: I do not see the point in using geometry here, because memoir has its
: own paper setting methods.

Just a bad habit of lazyness carried over from former documents
using article e.a. non-memoir document classes.

: In case of hyperref you can disable the
: media box setting by option `setpagesize=false` or correct \stockwidth
: and \stockheight:

: \usepackage[...]{geometry}
: \setlength{\stockwidth}{\paperwidth}
: \setlength{\stockheight}{\paperheight}

Thank you very much - I'll try both, first telling hyperref to behave
and then introduce correct settings using memoir's repertoire.

Thanks a lot!

Heiko Oberdiek

unread,
Sep 5, 2012, 4:34:25 AM9/5/12
to
Oliver Corff <co...@zedat.fu-berlin.de> wrote:

> Heiko Oberdiek <heiko.o...@googlemail.com> wrote:
> : Oliver Corff <co...@zedat.fu-berlin.de> wrote:
>
> : > Though I could
> : > not at all imagine that hyperref should in any conceivable manner
> : > interfere with geometry as these two areas seem to have so little
> : > in common,
>
> : All, memoir, geometry and hyperref, are setting the media box.
>
> which I did not know. What is the purpose of hyperref to set the
> media box?

Doing the job for LaTeX. In theory it would be the task for the kernel
to deal with media/paper sizes. But LaTeX2e is frozen long ago and
does not support PDF or PostScript, ...

> : The behaviour of hyperref is correct. It sets the media box to
> : \stockwidth and \stockheight that have priority over \paperwidth and
> : \paperheight in class memoir. Package geometry does not support
> : \stockwidth and \stockheight.
>
> To which purpose? Naively, I thought hyperref creates a link structure.

Then it is time to take a look into the manual.

--
Heiko Oberdiek

Oliver Corff

unread,
Sep 5, 2012, 9:30:41 AM9/5/12
to
Heiko Oberdiek <heiko.o...@googlemail.com> wrote:

: Doing the job for LaTeX. In theory it would be the task for the kernel
: to deal with media/paper sizes. But LaTeX2e is frozen long ago and
: does not support PDF or PostScript, ...

Thank you for the insight.

: Then it is time to take a look into the manual.

Westerwelle: "Wir haben verstanden." - read: I got the message.
0 new messages