# Tufte-Latex sidenote breaks indentation in alltt

I'm trying to the the alltt environment in tufte-book. My problem is that \sidenote seems to break the indentation in alltt.

\documentclass{tufte-book}
\usepackage{alltt}

\begin{document}

\begin{alltt}
Some text that asdfasfd  \sidenote{Side note}
some more text
\end{alltt}

\end{document}


Any suggestions?

• The verbatim environment does not either put the indentation space. I'm not sure that indentation has any sense inside a verbatim environment. – TeXtnik Jun 22 '12 at 13:24

## 1 Answer

\documentclass{tufte-book}
\usepackage{alltt}

\begin{document}

\begin{alltt}
Some text that asdfasfd \sidenote{Side note}
\parindent0pt{}some more text
\end{alltt}

\end{document}


Note you need to be very careful with white space in such an environment. You have to use {} after \parindent0pt a space that would normally be OK would be typeset here. Also \noindent (as used in the first draft) only works for one line, the next line would still be indented. (@egreg noted in chat)

One can patch \sidenote to behave properly in an alltt environment:

\documentclass{tufte-book}
\usepackage{alltt}

\makeatletter
\let\tufte@@sidenote\sidenote
\newcommand{\alltt@sidenote}[1]{\tufte@@sidenote{#1}\parindent=0pt}
\g@addto@macro\alltt{\let\sidenote\alltt@sidenote}
\makeatother

\begin{document}

\begin{alltt}
Some text that asdfasfd\sidenote{Side note} uuuu
some more text
and again text
\end{alltt}

\end{document}