lstlisting を使用するとテキスト行が揃わない

lstlisting を使用するとテキスト行が揃わない

すべての行が同じ列から始まるテキスト ボックスを作成したいのですが、ドキュメントをコンパイルすると、何らかの理由で行が揃いません。これが私のコードです:

\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}

コンパイルすると次のようになります:

ここに画像の説明を入力してください

私はxetexでコンパイルしていますが、それが重要かどうかはわかりません

答え1

が長すぎる行を分割する場合listings、新しい行の先頭にスペースが挿入されます。 を設定することでこのスペースを削除できbreakindent=0ptます\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}

ここに画像の説明を入力してください

関連情報