
Quero fazer uma caixa de texto onde cada linha comece na mesma coluna. Porém, quando compilo o documento, as linhas não ficam alinhadas por algum motivo. Aqui está meu código:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{listings}
\title{Example}
\lstset{basicstyle=\normalsize\ttfamily, breaklines=true}
\lstset{framextopmargin=10pt,framexbottommargin=10pt,frame=single}
\date{2012\\Julio}
\begin{document}
\maketitle
\noindent \textbf{\large{Example 1}}
\bigskip
\begin{lstlisting}
Example text. As you can see here, for some reason, and even though the first line of text is fine, the rest of the lines are not aligned
\end{lstlisting}
\end{document}
Aqui está o que recebo ao compilar:
Estou compilando com xetex, não sei se isso importa
Responder1
Ao listings
quebrar uma linha muito longa, ele insere algum espaço no início da(s) nova(s) linha(s). Você pode remover este espaço breakindent=0pt
configurando \lstset
:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{listings}
\title{Example}
\lstset{
basicstyle=\normalsize\ttfamily,
breaklines=true,
framextopmargin=10pt,
framexbottommargin=10pt,
frame=single,
breakindent=0pt % <-- NEW
}
\date{2012\\Julio}
\begin{document}
\maketitle
\noindent \textbf{\large{Example 1}}
\bigskip
\begin{lstlisting}
Example text. As you can see here, for some reason, and even though the first line of text is fine, the rest of the lines are not aligned
\end{lstlisting}
\end{document}