云彩店靠谱吗

Highlight source code in LaTeX with the lstlisting package.

The listings package offers source code highlighting for various languages. Learn by example how to use it in your LaTeX documents.


云彩店靠谱吗the listings package is a powerful way to get nice source code highlighting in latex. it's fairly easy to use and there's good documentation available on how to use it.

Example

云彩店靠谱吗the output of the listings package will pretty much look like this after some setup:

Image

\documentclass{article}

\usepackage{listings}
\usepackage{color}

\renewcommand\lstlistingname{Quelltext} % Change language of section name

\lstset{ % General setup for the package
	language=Perl,
	basicstyle=\small\sffamily,
	numbers=left,
 	numberstyle=\tiny,
	frame=tb,
	tabsize=4,
	columns=fixed,
	showstringspaces=false,
	showtabs=false,
	keepspaces,
	commentstyle=\color{red},
	keywordstyle=\color{blue}
}

\begin{document}
\begin{lstlisting}
#!/usr/bin/perl
print S(@ARGV);sub S{$r=(@_[0]%4==0&&@_[0]%100!=0)||@_[0]%400=0;}
\end{lstlisting}
\end{document}

I first use the include the color and listings package and then set up the language of the package headings to german using \renewcommand\lstlistingname{Quelltext}云彩店靠谱吗. This is not necessary if you're planning to use it in English.

Afterwards I set up the general layout for the package with the \lstset云彩店靠谱吗 command. The options I set there should be self-explanatory. Note that it's required to manually set the colors for keywords and comments, otherwise the output would be only black on white. The desired output must then be embedded within a listings environment.

assuming we have a perl script saved in a file script.pl, we could also simply use the following syntax to get the same result:

\lstinputlisting{script.pl}

this will keep your latex source clean and you can still use all features of the package.

Summary

  • After some initial setup, all source code can be embedded in a lstlistings environment
  • A list of all languages and more documentation is available in the manual of the listings package
  • Use the \lstlinputlisting{FILENAME} command to read the content of source files directly into a lstlistings environment.

Next lesson: 14 Circuitikz

乐优彩票天天红单下载 乐优彩票网址是多少 乐优炫彩app 乐优彩票登入,备用,官方网址 乐优炫彩天天红单 乐优炫彩app天天红单 乐优炫彩app下载 乐优炫彩官网 乐博彩票官方app 乐优炫彩彩票app下载