
Ich möchte ein Textfeld erstellen, bei dem jede Zeile in derselben Spalte beginnt. Wenn ich das Dokument kompiliere, sind die Zeilen jedoch aus irgendeinem Grund nicht ausgerichtet. Hier ist mein Code:
\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}
Folgendes erhalte ich beim Kompilieren:
Ich kompiliere mit xetex, ich weiß nicht, ob das wichtig ist
Antwort1
Wenn listings
eine zu lange Zeile umgebrochen wird, wird am Anfang der neuen Zeile(n) ein Leerzeichen eingefügt. Sie können dieses Leerzeichen entfernen, indem Sie Folgendes breakindent=0pt
festlegen \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}