3

Is it possible to add macro lengths
with manually coded numbers or with other macros
in a length input,
(as opposed to needing to use \addlength)?

MWE:

See \setlength{\xfootskip}{\xfootheight plus 0.25in}

[Please do not focus on use of KOMA with geometry ; j ]

\documentclass{scrreprt}

% Page size, margin, and header/footer settings:

% Enable "showframe" when editing margins
 \usepackage{showframe}                                     % Uncomment this to display header/footer/margins outlines.
 \usepackage{geometry}

% General margin settings:
 \newlength{\xhmargin   } \setlength{\xhmargin   }{1.000in}
 \newlength{\xlmargin   } \setlength{\xlmargin   }{1.500in}
 \newlength{\xrmargin   } \setlength{\xrmargin   }{\xhmargin}

 \newlength{\xtmargin   } \setlength{\xtmargin   }{1.000in} % Actual tmargin = [\xtmargin - \xheadheight]
 \newlength{\xbmargin   } \setlength{\xbmargin   }{1.000in} % Actual bmargin = [\xbmargin - \xfootskip  ]

% Header  margin settings:
 \newlength{\xheadheight} \setlength{\xheadheight}{0.500in}
 \newlength{\xheadsep   } \setlength{\xheadsep   }{1.000em}

% Footer  margin settings:
 \newlength{\xfootheight} \setlength{\xfootheight}{0.500in}
 \newlength{\xfootskip  } \setlength{\xfootskip  }{\xfootheight plus 0.25in} % [Set = Footheight + desired Footsep]



\KOMAoptions{fontsize   = 10pt,
             parskip    = half-,
             headings   = small,
             headheight = \xheadheight,
             footheight = \xfootheight,
             DIV        = current}

\geometry{letterpaper,
          tmargin       = \xtmargin,
          bmargin       = \xbmargin,
          lmargin       = \xlmargin,
          rmargin       = \xrmargin,
          headsep       = \xheadsep,
          footskip      = \xfootskip}


\begin{document}
A
\end{document}
  • 2
    \dimexpr\lenone+\lentwo? plus and minus does not calculate but defines a kind of stretchability for that length. – TeXnician Jun 24 '17 at 20:29
  • Ahh! I did not understand that upon reading the latex wiki. Thank you. – kando Jun 24 '17 at 20:32
4

The syntax

\setlength{\xfootskip}{\xfootheight plus 0.25in}

tells TeX that \xfootskip has natural width equal to \xfootheight and a stretchability of 0.25in.

Note that this works just because \xfootheight has no stretchability and shrinkability, otherwise you'd get an error message.

If you want to add the value, do

\setlength{\xfootskip}{1\xfootheight}
\addtolength{\xfootskip}{0.25in}

or

\setlength{\xfootskip}{\dimexpr\xfootheight+0.25in\relax}

The factor 1 is used to kill possible stretchability or shrinkability. In case you want to do arithmetic with rubber length (skips), you can use \glueexpr.

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.