Basic usage:
- \ Documentclass [utf8] {ctexart} utf8 can be omitted. Ctexart is an article that supports Chinese characters. If it is changed to Article, Chinese characters are not displayed.
- \ Title {......}
- \ Author {ooyyloo}
- \ Begin {document}
- \ End {document}
Insert code:
The inserted code must contain the listings macro package, and the xcolor macro package is required for code highlighting.
Add and set the listings and xcolor macro packages in the Introduction area.
\ Usepackage {listings} % insert Code \ usepackage {xcolor} % code highlight \ lstset {numbers = left, % set the row number position numberstyle = \ tiny, % set the row size keywordstyle =\color {blue}, % set the keyword color commentstyle = \ color [CMYK] {,}, % set the annotation color frame = single, % set the border format escapeinside = '', % escape character (the key on the left side of 1), used to display Chinese breaklines, % automatically fold extendedchars = false, % when the Code cross page is resolved, Chapter title, questions about non-display of headers and other Chinese characters xleftmargin = 2em, xrightmargin = 2em, aboveskip = 1em, % set margin tabsize = 4, % set the number of tab spaces showspaces = false % Do Not Display spaces}
You can use this when inserting code in the article:
\begin{lstlisting}[language=C]/* helloworld.c */#include <stdio.h>int main(){ printf("Hello World!\n"); return 0;}\end{lstlisting}
(Reference URL: http://blog.thebeyond.name/archives/33)
Latex Study Notes