Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
The verbatim environment does not either put the indentation space. I'm not sure that indentation has any sense inside a verbatim environment. –  zunbeltz Jun 22 '12 at 13:24
add comment

1 Answer

up vote 3 down vote accepted
\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} 
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.