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}

여기에 이미지 설명을 입력하세요

관련 정보