4

Is there a pre-defined width that covers both the text and margin areas? Correct me if I am wrong, but it would basically be equal to \textwidth+\marginparsep+\parginparwidth.

Is that provided by LaTeX somewhere?

If not, I am currently defining it this way in the preamble:

\newlength{\widewidth}
\setlength{\widewidth}{\textwidth+\marginparsep+\marginparwidth}

Is that the right approach? Are there any caveats? For example, if I change a page's orientation, would \widelength change its size to reflect that?

  • Have you tried \linewidth? – John Kormylo May 18 '14 at 13:40
  • @JohnKormylo Yes, \linewidth is the same as \textwidth. Should that not have been the case? – sudosensei May 18 '14 at 17:55
  • @sudosensei I haven't confirmed it, but I seem to recall that \linewidth and \textwidth are the same in the default configuration, but if you change the page's orientation, \textwidth does not change, but \linewidth does account for the revised orientation. Also, keep in mind that the \marginpar can be changed from the one side of the page to the other. While the overall width may stay the same, the beginning/ending locations on the paper will change. – Steven B. Segletes May 19 '14 at 2:23
  • @StevenB.Segletes Thanks for the explanation, Steven. The beginning and ending positions are decided by the figure* environment (from the sidenotes package) that places figures across the margin and text block. The length I am defining is only a convenience variable, really, so that I can say \includegraphics[width=\widewidth] - \textwidth and linewidth are the same as outside the figure* environment. I guess the question is whether this is the right way to define the length, assuming that starting/ending points have ben taken care of. – sudosensei May 19 '14 at 9:30
3

Once a user length is defined, it is fixed in physical units until reset by the user (see Defining a Length that Scales with Fontsize Changes). So the way you define a "length" that can adjust with page dimension changes is to define it as a macro \def in terms of the system lengths that are updated with format changes, rather than as a \setlength which will fix the length. In this manner, the \def is re-evaluated to its "current" value at every invocation.

Once that lesson is learned, the next aspect to your question is that \linewidth rather than \textwidth is the appropriate length to use when, for example, changing into landscape mode, etc. On page 1 of my MWE, it makes no difference which is used, but on page 2, one can see that the \linewidth definition gives the proper result, not the \textwidth result.

And finally, if \reversemarginpar is used, as is done on page 3 of the MWE, then extra provisions must be made

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{pdflscape}
\usepackage[nopar]{lipsum}
  \def\wrongwidewidth{\dimexpr\textwidth+\marginparsep+\marginparwidth}%
  \def\rightwidewidth{\dimexpr\linewidth+\marginparsep+\marginparwidth}%
\begin{document}
\lipsum[1]\marginpar{This is a test of a margin par}\vspace{2cm}\par
Doesn't matter\par
\noindent\includegraphics[width=\wrongwidewidth]{test}

Doesn't matter\par
\noindent\includegraphics[width=\rightwidewidth]{test}
\begin{landscape}
  \lipsum[2]\marginpar{This is a test of a margin par}\vspace{2cm}\par
  Wrong\par
  \noindent\includegraphics[width=\wrongwidewidth]{test}

  Right\par
  \noindent\includegraphics[width=\rightwidewidth]{test}
\end{landscape}

With reverse marginpar, tricks must be done\vspace{2cm}\par\reversemarginpar
\lipsum[1]\marginpar{This is a test of a margin par}\vspace{2cm}\par
Doesn't matter\par
\noindent\makebox[\linewidth][r]{\includegraphics[width=\wrongwidewidth]{test}}

Doesn't matter\par
\noindent\makebox[\linewidth][r]{\includegraphics[width=\rightwidewidth]{test}}
\end{document}

enter image description here

enter image description here

enter image description here

  • Very well explained. I wasn't aware of the difference between \textwidth and \linewidth. Thank you, Steven! – sudosensei May 19 '14 at 11:08

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.