LaTex中文显示及listings宏包的使用

 

\documentclass[11pt,a4paper]{article}
\usepackage{xltxtra}
\usepackage{fontspec}
\usepackage{float}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{color}
\usepackage[top=0.8in,bottom=0.8in,left=1.2in,right=0.6in]{geometry}
\lstset{
  language=[ANSI]c,
  basicstyle=\small,
  numbers=left,
  keywordstyle=\color{blue},
  numberstyle={\tiny\color{lightgray}},
  stepnumber=1, %行号会逐行往上递增
  numbersep=5pt,
  commentstyle=\small\color{red},
  backgroundcolor=\color[rgb]{0.95,1.0,1.0},
  showspaces=false,
  showtabs=false,
  frame=shadowbox, framexleftmargin=5mm, rulesepcolor=\color{red!20!green!20!blue!20!},
% frame=single,
%  TABframe=single,
  tabsize=4,
  breaklines=tr,
  extendedchars=false %这一条命令可以解决代码跨页时,章节标题,页眉等汉字不显示的问题
}


%字体
\setmainfont[BoldFont={SimHei},ItalicFont={KaiTi}]{SimSun}
\setsansfont[BoldFont=SimHei]{KaiTi}
\setmonofont{NSimSun}

%%设置中文
%中文断行
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt

\begin{document}
此页故意留作空白
\newpage
\subsection{LaTex汉字测试}
测试文件

\lstinputlisting{src/function.h}
\lstinputlisting{src/function.c}
\begin{lstlisting}
int main(int argc, char ** argv)
{
/* 测试汉字注释 */
printf("Hello world!\n");

return 0;
}
\end{lstlisting}

\end{document}

 

 



转载于:https://www.cnblogs.com/shaoguobao/archive/2011/07/21/2113013.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值