標籤:style blog http color io 使用 ar strong for
基礎使用:
- \documentclass[UTF8]{ctexart} UTF8可省略。ctexart為支援中文的文章,若改為article則不顯示中文。
- \title{……}
- \author{ooyyloo}
- \begin{document}
- \maketitle
- ……
- \section{文字}
-
\[ a^2+b^2=c^2 \]
- \end{document}
插入代碼:
在中插入代碼需要包含listings宏包,而想要代碼高亮需要xcolor宏包。
在導言區加入listings和xcolor宏包,並對其設定。
\usepackage{listings} %插入代碼\usepackage{xcolor} %代碼高亮 \lstset{numbers=left, %設定行號位置 numberstyle=\tiny, %設定行號大小 keywordstyle=\color{blue}, %設定關鍵字顏色 commentstyle=\color[cmyk]{1,0,1,0}, %設定注釋顏色 frame=single, %設定邊框格式 escapeinside=``, %逃逸字元(1左面的鍵),用於顯示中文 breaklines, %自動折行 extendedchars=false, %解決代碼跨頁時,章區段標頭,頁首等漢字不顯示的問題 xleftmargin=2em,xrightmargin=2em, aboveskip=1em, %設定邊距 tabsize=4, %設定tab空格數 showspaces=false %不顯示空格 }
文章中需要插入代碼時可以這樣使用:
\begin{lstlisting}[language=C]/* helloworld.c */#include <stdio.h>int main(){ printf("Hello World!\n"); return 0;}\end{lstlisting}
(參考網址:http://blog.thebeyond.name/archives/33)
LaTex 學習筆記