Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I somehow have the feeling this is a dumb question, but I just can't find anything :-(

How can I determine the actual values of the inner and outer margins of my document, or still better: the right and left margins of the current page?

Background is that I'm working on a package to manage music examples, and one of the kinds these come are multi-page pdf files. Additional to other methods I would like to add an option to automatically offset the included pdf pages depending on being on an odd or even page.

For this I would like to read out the margins of the current page.

share|improve this question
    
The packages layouts and layout can help you. –  Marco Daniel Mar 10 '13 at 18:41
    
Unfortunately neither of these suggestions helps me: I don't need to determine if I'm on an odd side (I have this already), and I don't need to display layout values, but I have to read and use them. So it would be best if these values were stored in counters that I can simply read out. –  uli_1973 Mar 10 '13 at 19:12
    
@uli_1973: When you use the \layout package, not only does it display the values, but it also tells you the name of the length registers that contain those values. –  Peter Grill Mar 11 '13 at 3:30
    
@Peter: I'm sorry, obviously I didn't think far enough. Of course \layout doesn't give me directly what I want, but provides me with the tools to do so. –  uli_1973 Mar 11 '13 at 17:59
add comment

2 Answers

up vote 4 down vote accepted

The reference point (unless changed with \hoffset and \voffset) is 1in in and 1in down from the top left of the page.

Relative to that point the left margin in LaTeX is \oddsidemargin on odd pages and \evensidemargin on even pages. The total paper width is \paperwidth so the right margin on an odd page is \paperwidth - \textwidth - \oddsidemargin - 1in.

share|improve this answer
add comment

To read and use margin lengths and the like, check this MWE. The \layoutcommand of the package layout show all the relevant lengths about margins, so IMHO the comment of Marco Daniel it is really a good suggestion. Another could be the use of the package geometry to fix yourself the margin values.

\documentclass[twoside,a4paper]{article}
%\usepackage[margin=2cm]{geometry}
%\usepackage{layout}
\begin{document}
% \layout 
The text width is now \the\textwidth

\rule{\textwidth}{0.4pt}

The odd side margin is now \the\oddsidemargin ~
\rule{\oddsidemargin}{0.4pt}

The even side margin is now \the\evensidemargin ~
\rule{\evensidemargin}{0.4pt} 

The top margin is now \the\topmargin  ~
\rule{\topmargin}{0.4pt}

\end{document}
share|improve this answer
    
Sorry, but I can only accept one answer. Yours was more practical to get a feeling for the syntax, but the other one provides important information about the reference point. –  uli_1973 Mar 11 '13 at 18:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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