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:
\documentclass[12pt,a4paper]{article}
\usepackage[pass]{geometry}
\usepackage{tikz,enumitem}
\usepackage{fix-cm}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Junicode}
\usepackage{layouts}
\usepackage{etoolbox}
\patchcmd{\drawpage}{\ifdrawparameters}{\iftrue}%
{\typeout{^^J*******\string\drawpage fixed*******^^J}}%
{\typeout{^^J*******\string\drawpage not fixed*******^^J}}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
Trying
some
text
\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) {%
\begin{minipage}{\paperwidth}%
\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 %
\end{minipage}
}%path
;
\end{scope}
\end{tikzpicture}
\end{document}
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:
\documentclass[12pt,a5paper]{article}
...
... 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:
\documentclass[12pt,a5paper]{article}
...
\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,
Cheers!




0.7071067811865475which is (close to)1/sqrt(2)at least keeps the text within the box. – Phantrast Jan 05 '13 at 13:45