Tell me more ×
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.

My verbatim environment allows text to go way beyond margins and off the page, I am using the \begin{alltt} version though. Below is my entire preamble:

\documentclass{llncs}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{tabularx}
\usepackage{courier}
\usepackage{alltt}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\newcommand{\imp}[1]{\underline{\textbf{#1}}}
\newcommand{\bo}[1]{\textbf{#1}}
\newcommand{\colour}[2][Blue]{\textcolor{#1}{#2}}
\newcommand{\ita}[1]{\textit{#1}}
\newcommand{\pic}[2]{\centerline{\includegraphics[0.7\textwidth]{#2}}}
\newcommand{\wpic}[3][\dimexpr\textwidth-1em\relax]{%
\par\noindent\mbox{%
\begin{minipage}{0.4\textwidth}
\includegraphics[width=#1]{#2}
\end{minipage}%
\begin{minipage}{0.6\textwidth}
#3
\end{minipage}}
\par}
\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\tab}{\hspace{15pt}}

Can anyone help me to get the \begin{alltt} to fit my code within the text margins?

share|improve this question
Do you use alltt in conjunction with listings? This post might help: tex.stackexchange.com/questions/48711/… – hpesoj626 Nov 30 '12 at 4:30
verbatim is required to obey everything you write, so there's no surprise there. however, tt fonts in general don't allow hyphenation, so they are inevitably prone to overrunning margins, hence the alltt problem. – wasteofspace Nov 30 '12 at 8:02
if instead of actual verbatim you mean alltt, it's possible that localized \raggedright might help. – barbara beeton Dec 1 '12 at 19:30
Not using the listings package, I saw that post actually so it didn't help :(, I guess what I am trying to do is display code in a typewriter font in the middle of a regular latex document, perhaps anyone has a better solution? – Dan Dec 1 '12 at 21:12
Would shrinking the size of the verbatim text, so that it doesn't go off the margin work for you? (or are you way off in the margin?) – Steven B. Segletes May 17 at 18:10

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.