Indent A Code Listing In LaTeX


Answer :

The listings package allows you to change the margins (see section 4.10 of the documentation.)

\lstset{numbers=right,                 numberstyle=\tiny,                 breaklines=true,                backgroundcolor=\color{light-gray},                numbersep=5pt,                xleftmargin=.25in,                xrightmargin=.25in} 

Adjust as necessary.


You can do this using the xleftmargin option of listings. See the manual page 33, section 4.10 "Margins and line shapes".

Example:

\documentclass{article}\usepackage{lipsum}\usepackage{color}\definecolor{light-gray}{gray}{0.95}\usepackage{listings} \lstset{numbers=right,                 numberstyle=\tiny,                 breaklines=true,                backgroundcolor=\color{light-gray},                xleftmargin=\parindent,                %xleftmargin=1cm,                %xrightmargin=\parindent,                numbersep=5pt} \lstset{language=SQL} \begin{document}\lipsum[1]\begin{lstlisting}{insert}INSERT INTO Tabelle (Spalte1, Spalte2, Spalte3) VALUES (Wert1, Wert2, Wert3);\end{lstlisting}\lipsum[2]\end{document}

Belum ada Komentar untuk "Indent A Code Listing In LaTeX"

Posting Komentar

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel