| 1 |
%% |
| 2 |
%% This is file `xeCJK-example-listings.tex', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% xeCJK.dtx (with options: `ex-listings') |
| 8 |
%% |
| 9 |
\documentclass{article} |
| 10 |
\usepackage[margin=1in]{geometry} |
| 11 |
\usepackage{listings,xcolor} |
| 12 |
\usepackage{showexpl} |
| 13 |
|
| 14 |
\usepackage{xeCJK} |
| 15 |
\setCJKmainfont{HanaMinA} |
| 16 |
\setCJKmonofont{SimSun} |
| 17 |
\xeCJKDeclareSubCJKBlock{Kana} { "3040 -> "309F, "30A0 -> "30FF, "31F0 -> "31FF } |
| 18 |
\setCJKmonofont[Kana]{Meiryo} |
| 19 |
\setmonofont{Latin Modern Mono Light} |
| 20 |
|
| 21 |
\makeatletter |
| 22 |
\lstset{% |
| 23 |
basicstyle=\small\ttfamily,breakindent=4\lst@width, |
| 24 |
numbers=left,numberstyle=\tiny\color{gray}, |
| 25 |
commentstyle=\color{green!50!black},keywordstyle=\color{blue}\bfseries, |
| 26 |
identifierstyle=\color{violet},stringstyle=\color{brown}, |
| 27 |
escapebegin=\normalfont} |
| 28 |
\lstnewenvironment{cppcode}[1][] |
| 29 |
{\lstset{language=C++,#1}} |
| 30 |
{} |
| 31 |
\makeatother |
| 32 |
|
| 33 |
\begin{document} |
| 34 |
|
| 35 |
\section{\lstinline{\\lstinline} 测试} |
| 36 |
|
| 37 |
\section{\lstinline|甲*乙| 测试} |
| 38 |
|
| 39 |
\lstinline|abc汉字abc| |
| 40 |
|
| 41 |
\lstinline|甲*乙| |
| 42 |
|
| 43 |
\lstinline[mathescape]|数学公式$x^2+y^2$| |
| 44 |
|
| 45 |
\section{\lstinline{lstlisting} 环境测试} |
| 46 |
|
| 47 |
\begin{lstlisting}[basicstyle=\rmfamily] |
| 48 |
纯文字text测试 |
| 49 |
纯文字text测试 |
| 50 |
文字+文字 |
| 51 |
文字(符号)文字 |
| 52 |
辻󠄂辻󠄃辻󠄄辻󠄅 |
| 53 |
かがか゚ |
| 54 |
\end{lstlisting} |
| 55 |
|
| 56 |
\begin{lstlisting} |
| 57 |
text纯文字测试 |
| 58 |
\end{lstlisting} |
| 59 |
|
| 60 |
\begin{lstlisting} |
| 61 |
text 纯文字测试 |
| 62 |
\end{lstlisting} |
| 63 |
|
| 64 |
\begin{lstlisting} |
| 65 |
text,纯文字测试 |
| 66 |
\end{lstlisting} |
| 67 |
|
| 68 |
\section{自定义环境测试} |
| 69 |
|
| 70 |
\begin{LTXexample}[pos=t,varwidth,numbersep=5pt,columns=fixed] |
| 71 |
\begin{cppcode}[escapechar=`,morekeywords=返回] |
| 72 |
#define 返回 return |
| 73 |
#include <iostream> |
| 74 |
/* |
| 75 |
* 块注释 |
| 76 |
* `逃逸字符,测试$f(x)$` |
| 77 |
*/ |
| 78 |
int main() |
| 79 |
{ |
| 80 |
// 行注释 |
| 81 |
const char *欢迎 = "hello 世界(ワールド)"; |
| 82 |
std::cout << 欢迎 << std::endl; |
| 83 |
返回 0; |
| 84 |
} |
| 85 |
\end{cppcode} |
| 86 |
\end{LTXexample} |
| 87 |
|
| 88 |
\section{\texttt{breaklines} 测试} |
| 89 |
|
| 90 |
\begin{lstlisting}[linewidth=10em,frame=single,rulecolor=\color{black},breaklines] |
| 91 |
断行文字text测试,断行文字text测试,断行文字text测试,断行文字text测试 |
| 92 |
断行文字text测试,断行文字text测试,断行文字text测试,断行文字text测试 |
| 93 |
\end{lstlisting} |
| 94 |
|
| 95 |
\section{\lstinline|\\lstinputlisting| 测试} |
| 96 |
|
| 97 |
\lstinputlisting[language={[AlLaTeX]TeX}]{\jobname} |
| 98 |
|
| 99 |
\end{document} |
| 100 |
%% |
| 101 |
%% |
| 102 |
%% End of file `xeCJK-example-listings.tex'. |