I am currently working on a project with xelatex/fontspec and tikz, and so, this example is basically the same as the one from layouts package reads all length as zero with tikz/fontspec/xelatex?.

Basically, I'm trying to typeset some text - and then, using the layouts package to draw a visualization of the page, in a tikz node aligned to the upper right corner of "the paper size" (as opposed to "the page", which would refer to the space within the margins of the ... well... the page :)). The problem - everything seems to work as expected for A4 size; but things seem strange when switching to A5.

Here is the MWE (test.tex), formulated for A4 page, and compiled with xelatex test.tex:






  {\typeout{^^J*******\string\drawpage fixed*******^^J}}%
  {\typeout{^^J*******\string\drawpage not fixed*******^^J}}







\begin{tikzpicture}[overlay,remember picture,inner sep=0pt,yscale=-1,outer sep=0pt,anchor=north west]

  \begin{scope}[shift={(0pt,0pt)}]% layer1

  %\path[..] (0,0) node[below right] (dbg) {% this goes to (0,0) - but after margin
  %\path[..] (current page.north west) node[below right] (dbg) {% this goes to (0,0) - but before margin; that is, upper right corner of paper size

  \path[anchor=north west] (current page.north west) node[below right] (dbg) {%
        \setlayoutscale{1} % {1} for A4; {0.7} for A5
        \printparametersfalse % do not print table of parameters at end; no effect on \drawpage
        \printheadingsfalse % do not print the "The circle is at 1 inch from the ... " headings; works only for \pagedesign
        \drawdimensionstrue %
%           \trypaperwidth{\paperwidth}
%           \trypaperheight{\paperheight}
%           \tryhoffset{\hoffset}
%           \tryvoffset{\voffset}
%           \tryoddsidemargin{\oddsidemargin}
%           \tryevensidemargin{\evensidemargin}
%           \trymarginparwidth{\marginparwidth}
%           \trymarginparsep{\marginparsep}
%           \trymarginparpush{\marginparpush}
%           \trytopmargin{\topmargin}
%           \tryheadheight{\headheight}
%           \tryheadsep{\headsep}
%           \tryfootskip{\footskip}
%           \trytextheight{\textheight}
%           \trytextwidth{\textwidth}
%           \trycolumnsep{\columnsep}
%           \trycolumnseprule{\columnseprule}
        \currentpage % "collects together the page parameter settings for the current document for the page on which it is issued."
        \currentparagraph % "sets the drawing parameters to the settings for the current document."
%         \drawpage
        \pagedesign %
%         \pagediagram %




Note that above, I've written and commented the \try... commands, to keep in mind that that is what the \currentpage macro should do - and to also keep in mind, that if I specificially set a length there, then the produced page layout diagram should be modified accordingly (as much as I can understand the documentation, layman.pdf, that is)

When this document is built (after running xelatex twice), I get the following pdf (click on images for full size):

Now, I'm not sure if paragraph text should be typeset in the \headsep space below the header - but other than that, diagram seems reasonable to be.

Ok, now, let's just replace document class to A5 paper size:


... after compiling twice, one can see something is not right in the pdf:

To me, it looks like the layouts package still draws dimensions and lengths for A4 - even if the page should be now changed to A5 !

So, I thought, OK , lets also modify the layout scale, so we'd now have:

        \setlayoutscale{0.7} % {1} for A4; {0.7} for A5

... which results with the following PDF, when compiled twice:

Again, this looks sort of reasonable - but I've scaled dimensions manually, "by eyeballing", which I don't like; and also text runs outside of the right body margin, and doesn't start exactly at top body margin.

Finally, if in this case I try to do something very obvious, such as enabling a statement like \tryheadheight{50pt} from the \try.. statements there - there is absolutely no change in the drawn height of the header.


So, if there is a right way in using the layouts package, so I get accurate lengths visualization in this case, I'd love to know it - but I guess, all this should tell me that, unfortunately, I actually cannot get accurate visualization of dimensions with layouts package? Can anyone please confirm?

Many thanks in advance for any asnwers,

  • I guess this isn't the solution you're looking for, but for A5 setting the layoutscale to 0.7071067811865475 which is (close to) 1/sqrt(2) at least keeps the text within the box. – Phantrast Jan 5 '13 at 13:45

Here's a version of what you describe that does not use TikZ. It suggests that your problem is with how you have used layouts inside tikz rather than with layouts itself.

\newdimen\dx \dx=1in \advance\dx\hoffset \advance\dx\oddsidemargin
\newdimen\dy \dy=1in \advance\dy\voffset \advance\dy\topmargin 
\advance\dy\headheight \advance\dy\headsep \advance\dy2.4\baselineskip
\moveright-\dx\vbox to 0pt{\vskip-\dy\leavevmode
   \printheadingsfalse \printparametersfalse
   \currentpage \setlayoutscale 1 \pagedesign \vss}

I've used TeX primitives to try to keep it simple and eliminate possible interactions with other packages. \newdimen\dx creates a new dimension variable dx which is then set to 1in+\hoffset+\oddsidemargin, and similarly for dy. We then create a vbox to hold the layout diagram, which we move to the right using \moveright. The vskip at the top of the box creates some negative space at the top and the \vss at the bottom expands to shove the contents up to fill the negative space. The whole box is set to 0pt so that it takes up no vertical space on the page.

Beware that you will get an "overfull \hbox" error when you process this. Here's the output with the a5paper option at the top.

example layout

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.