
Quiero crear un cuadro de texto donde cada línea comience en la misma columna. Sin embargo, cuando compilo el documento, las líneas no están alineadas por algún motivo. Aquí está mi 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}
Esto es lo que obtengo al compilar:
Estoy compilando con xetex, no se si eso importa
Respuesta1
Cuando listings
se divide una línea que es demasiado larga, se inserta un espacio al principio de la(s) nueva(s) línea(s). Puede eliminar este espacio configurando breakindent=0pt
en \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}