# Memoir rounds down textwidth to nearest pt after checkandfixthelayout

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}


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

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
\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}