I am trying to use the textpos package to absolute-position a textblock in the upper left corner of the text area on my page (i.e. inside the page margins). I know I can get the width of the text by using \textwidth. But what are the corresponding commands to get distances like the left-margin, right-margin, top-margin and bottom-margin?
Asked
Active
Viewed 420 times
3
stack-delay
- 821
2 Answers
3
The package layout will show you all the lengths and their actual values:
\documentclass{article}
\usepackage{layout}
\begin{document}
\layout
\end{document}
Fran
- 80,769
2
You need no measurement, except knowing about \topskip:
\documentclass{article}
\usepackage[showboxes]{textpos}
\usepackage{showframe}
\begin{document}
\begin{textblock*}{3cm}(0pt,-\topskip)
\noindent some text \\ 3cm wide
\end{textblock*}
\end{document}
To answer your question, the top left corner of the text block is
\oddsidemargin+\hoffset+1in
\evensidemargin+\hoffset+1in
from the left border of the page (depending if on an odd or even page, in oneside mode all pages are considered to be odd) and
\topmargin+\voffset+\headheight+\headsep+1in
from the top border of the page.
The parameters \hoffset and \voffset are commonly zero and they should remain such: they're thought for small corrections for coping with printing devices and they should never be used for setting the page dimensions.
The textblock* environment places the box at the prescribed position, but apparently it doesn't keep into consideration the \topskip.
egreg
- 1,121,712
-
That's right:
textblockin relative mode (the default) places boxes relative to the point in the page where thetextblockis invoked, whereever that happens to be;textblockin absolute mode places boxes relative to the top-left of the page. In each case, it doesn't consider\topskipor any other such parameter. – Norman Gray Feb 13 '17 at 09:08


\headheight,\footskip,\evensidemargin,\oddsidemargin,\leftmargin? – Feb 11 '17 at 11:38