2

Using memoir with LuLaTeX, I noticed that \checkandfixthelayout rounds down textwidth to the nearest pt. How can I prevent this rounding? In the example below, I'm missing 0.35 pt from textwidth.

Edit:

I looked at memoir.cls (v3.7f, 2016/05/16) line number 1295 and found that \textwidth is actually rounded down to the nearest pt with \@settopoint. My problem disappeared by commenting out that line. I also commented out the two next ones that did the same to \oddsidemargin and \evensidemargin. I wonder if this is safe. I also wonder why the code is like this in the first place. Why round down? I want to set \textwidth exactly.

\documentclass[a4paper]{memoir}
\usepackage{calc}

\settrims{0mm}{0mm}
\setlength{\textwidth}{127mm}
\setlrmargins{*}{*}{*}
\checkandfixthelayout  % options: fixed, classic, lines, nearest

\begin{document}
\newlength{\mylength}
\setlength{\mylength}{\spinemargin+\textwidth+\foremargin}%
\noindent spinemargin + textwidth + foremargin =\\ \the\spinemargin\ + \the\textwidth\ + \the\foremargin\ = \the\mylength

\ \newline
paperwidth = \the\paperwidth
\end{document}

enter image description here

  • In the next memoir release there will be a class option to disable this truncation feature. – daleif Mar 9 '18 at 11:40
2

Just for others how are interested. The safest way to "ignore" \@settopoint in this case is probably the code below.

I asked Peter Wilson, the memoir author. The only reason he had what that it looked better when printed. But then again it is only done for some lengths.

In a future version we'll probably rewrite this such that the use of \@settopoint is something that is easier to remove.

\makeatletter
\let\normalsettopoint\@settopoint
% this just writes the lengths that would be adjustsed to log
\def\@settopoint#1{\typeout{\string#1}}
\makeatother
\documentclass[a4paper]{memoir}

% run margins as soon as possible
\setlength{\textwidth}{127mm}
\setlrmargins{*}{*}{*}
\checkandfixthelayout  % options: fixed, classic, lines, nearest
% restore \@settopoint just if other packages rely on it, has to go
% AFTER margin adjustments
\makeatletter
\let\@settopoint\normalsettopoint
\makeatother


\begin{document}

\newlength{\mylength}

\setlength{\mylength}{\dimexpr\spinemargin+\textwidth+\foremargin}%

spinemargin + textwidth + foremargin =

\the\spinemargin\ + \the\textwidth\ + \the\foremargin\ = \the\mylength


\bigskip


paperwidth = \the\paperwidth

 \end{document}
| improve this answer | |

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.