# pagenote converts spaces to newlines and breaks verbatim typesetting

I want to typeset verbatim end notes (using minted). Unfortunately pagenote converts all spaces in my page notes into newlines, as the following minimal example shows:

\documentclass{memoir}
\makepagenote
\begin{document}
main text
\pagenote[1]{page note text}
\printpagenotes
\end{document}


Looking at the generated *.ent file we see that every space in the pagenote has been converted to a newline:

\startnoteentry{0}
{1}
{pagenote1-1}
{}
page
note
text
\endnoteentry


How can I prevent this conversion, so that I can use verbatim typesetting in pagenotes?

Are there alternative ways of typesetting verbatim end notes?

• Verbatim cannot be used in macros. The page notes converts spaces to new lines because of the build in limit of how many characters there can be on a line. Some users hit that limit – daleif Apr 22 at 18:21
• Thanks @daleif. Do you know how to switch this behavior off? I will not reach that limit. – Roman Apr 23 at 20:46
• Not at pc, will have a look tomorrow if I have the time – daleif Apr 23 at 20:47
• I'm now sure there is a way around this. The issue with very long lines, was the fact that when the input becomes available to be written to disk again, the newlines have already been absorbed and thus you just get a long string of data separated by spaces (and having \par instead of blank lines). I'm guessing this comes from the fact that we are using a macro here, aka the input is the argument to a macro. Environments can do this mainly because they can process the data in a different manner than macros. – daleif Apr 24 at 7:35
• You can see the issue if you copy the definition of \m@m@wrpnote (remember \renewcommand and \makeatletter/-other, then then out comment the \newlinechar line. Then verbatim input the notes file via \verbatiminput{\jobname.ent} (you probably need a dummy minted env) – daleif Apr 24 at 7:38

Too long for a comment.

Here is an example file showing what is actually going on. The patch removed the \newlinechar='40 and then it defaults to -1. As one can see by running this, at this point when we are given the data, the original newlines have already been converted into spaces, and thus it is too late to do anything. If you absolutely need to have minted in page notes (I'd probably reconsider and use an appendix or similar), then you probably need an environment based interface for writing these pesky chunks to the ent file.

\documentclass{memoir}
\makepagenote
\usepackage{minted}

%\newenvironment{minted}[1]{\par\medskip}{\par}

\usepackage{xpatch}
\tracingpatches
\makeatletter
\xpatchcmd{\m@m@wrpnote}{\newlinechar='40}{}{\typeout{patched}}{\typeout{nope}}
\makeatother

\begin{document}
main text
\pagenote[1]{
\begin{minted}{latex}
test LaTeX test

\end{minted}
asdf}

%\printpagenotes

% just so we never run the minted env
\makeatletter
\immediate\closeout\@notefile
\makeatother

The actual ent file:

\verbatiminput{\jobname.ent}

\end{document}
`

• Amazing solution, @daleif! I will accept it after a few more checks. Thanks! – Roman Apr 24 at 8:50
• @Roman it is not a solution, it just explains why one cannot do what you want to. – daleif Apr 24 at 9:13
• Yes I see now what you mean. After some experimentation with your input I think I'll follow your advice and do a proper appendix. Thanks anyway! – Roman Apr 24 at 14:40