5
\def\leftmargin{1.25in}          % custom margin
\hoffset \leftmargin - 1in       % subtract 1in from \leftmargin, !Not working
\hoffset \leftmargin minus1in    % also tried this with no success


% In effect, \hoffset should be 0.25in

How do I use simple expression while setting dimensions in Plain TeX?

4
  • 1
    Welcome ` Check \newdimen\leftmargin \leftmargin=1.25in instead of \def\leftmargin
    – GowriSaro
    Commented Dec 16, 2022 at 6:28
  • But, -1in is literally printed on page. Subtraction has not occured. i.e. margin is still 1.25in. Commented Dec 16, 2022 at 6:39
  • 1
    You can use \dimexpr Commented Dec 16, 2022 at 7:29
  • 1
    \hoffset \leftmargin \advance \hoffset -1in
    – user206750
    Commented Dec 16, 2022 at 7:30

2 Answers 2

9

With Knuth's original TeX (tex):

\newdimen\leftmargin
\leftmargin=1.25in
\hoffset=\leftmargin
\advance\hoffset by -1in
\showthe\hoffset

With e-TeX (etex, pdftex, xetex, luatex):

\def\leftmargin{1.25in}
\hoffset=\dimexpr\leftmargin - 1in
\showthe\hoffset

Both give an output of

> 18.0675pt.

which is the same as 0.25in.

5

With OpTeX:

\hoffset=1.25in

That is all. The left margin will be 1.25in after such setting, because OpTeX removes the "1in confusion" and "wasted calculation", because it sets the original point (0,0) to the upper-left corner of the paper sheet directly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .