服务器系列之制作使用手册的XeLaTeX模板

  • 导言区preamble_xelatex.tex

  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    
    documentclass[11pt,a4paper,twoside]{book}
     
    usepackage{fontspec}
    setmainfont{Times New Roman}
    setsansfont{Arial} 
    setmonofont{Courier New}
     
    usepackage[BoldFont,SlantFont,CJKchecksingle,CJKnumber]{xeCJK} 
    setCJKmainfont[BoldFont={Adobe Heiti Std},ItalicFont={Adobe Kaiti Std}]{Adobe Song Std} 
    setCJKsansfont{Adobe Heiti Std} 
    setCJKmonofont{Adobe Fangsong Std} 
    punctstyle{hangmobanjiao}
     
    defaultfontfeatures{Mapping=tex-text} 
    usepackage{xunicode} 
    usepackage{xltxtra}
     
    XeTeXlinebreaklocale zh 
    XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt
     
    %usepackage{indentfirst} 
    makeatletter 
    let@afterindentfalse@afterindenttrue 
    @afterindenttrue 
    makeatother 
    setlength{parindent}{2em} 
     
    linespread{1.5}
     
    usepackage{xcolor}
     
    usepackage[xetex,bookmarksnumbered=true,bookmarksopen=true,pdfborder=1,breaklinks,colorlinks,linkcolor=blue,urlcolor=blue]{hyperref}
     
    usepackage[top=1.2in,bottom=1.2in,left=1.2in,right=1in]{geometry}
     
    usepackage[center,pagestyles]{titlesec}
     
    titleformat{section}{centeringLargebfseries}{S,thesection}{1em}{} 
    titleformat{subsection}{largebfseries}{S,thesubsection}{1em}{}
     
    %单面模式 
    newpagestyle{main}{ 
    sethead[$cdot$~thepage~$cdot$][][chapternamequadchaptertitle]{smallS,thesectionquadsectiontitle}{}{$cdot$~thepage~$cdot$} 
    setfoot{}{}{}headrule} 
    pagestyle{main}
     
    usepackage{graphicx} 
    graphicspath{{figures/}}
     
    usepackage{titlesec}
     
    renewcommand{today}{numberyear 年 numbermonth 月 numberday 日} 
    renewcommand{contentsname}{目录} 
    renewcommand{listfigurename}{插图目录} 
    renewcommand{listtablename}{表格目录} 
    renewcommand{partname}{第 thepart 部} 
    renewcommand{chaptername}{第 CJKnumber{thechapter} 章} 
    titleformat{chapter}{centeringnormalfontHugebfseries}{chaptername}{20pt}{Huge} 
    renewcommand{figurename}{图} 
    renewcommand{tablename}{表}
    %renewcommand{bibname}{参考文献} 
    renewcommand{appendixname}{附录} 
    renewcommand{indexname}{索引} 
    %renewcommand{abstractname}{摘要} 
    %renewcommand{refname}{参考文献} 
    %renewcommand{equationautorefname}{公式} 
    %renewcommand{footnoteautorefname}{脚注} 
    %renewcommand{itemautorefname}{项} 
    renewcommand{figureautorefname}{图} 
    %renewcommand{tableautorefname}{表} 
    %renewcommand{appendixautorefname}{附录} 
    %renewcommand{theoremautorefname}{定理} 
     
     
    %插入源代码 
    usepackage{listings} 
    lstset{ 
     language=bash, % 程序语言名称:TeX, Perl, R, sh, bash, Awk 
     basicstyle=normalsizett, %tt指monospace字体族,程序源代码使用此族字体表示更加美观 
     numbers=left, % 行号位置(左侧) 
     numberstyle=small, % 行号字体的字号 
     stepnumber=1, % 行号的显示步长 
     numbersep=5pt, % 行号与代码间距 
     backgroundcolor=color{white}, % 背景色;需要 usepackage{color} 
     showspaces=false, % 不显示空格 
     showstringspaces=false, % 不显示代码字符串中的空格标记 
     showtabs=false, % 不显示 TAB 
     tabsize=4,  
     frame=shadowbox, % 把代码用带有阴影的框圈起来 
     captionpos=b, % 标题位置 
     breaklines=true, % 对过长的代码自动断行 
     breakatwhitespace=false, % 断行只在空格处 
     extendedchars=false, % 解决代码跨页时,章节标题,页眉等汉字不显示的问题 
    % escapeinside={%*}{*}, % 跳脱字符,添加注释,暂时离开 listings  
     escapeinside=``, 
     commentstyle=color{red!50!green!50!blue!50}tt, %浅灰色的注释 
     rulesepcolor=color{red!20!green!20!blue!20}, %代码块边框为淡青色 
     keywordstyle=color{blue!70}bfseriestt, %代码关键字的颜色为蓝色,粗体 
     identifierstyle=tt, 
     stringstyle=tt, % 代码字符串的特殊格式 
     keepspaces=true, 
     breakindent=22pt, 
     flexiblecolumns=true, 
     breakautoindent=true, 
     breakindent=4em, 
     aboveskip=1em, %代码块边框 
     xleftmargin=2em, 
     xrightmargin=2em 
    }
     
    %使表格可以跨页
    usepackage{booktabs,longtable}
     
    %画虚线 
    usepackage{arydshln}
     
    %使用盒子(文本框) 
    usepackage{fancybox}
     
    %插入PDF文档 
    usepackage{pdfpages}
  • 正文manual.tex

  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    input{preamble_xelatex.tex}
     
    begin{document}
     
     
    lstset{numbers=left,numberstyle=tiny, keywordstyle=color{blue!70}, commentstyle=color{red!50!green!50!blue!50}, frame=shadowbox, rulesepcolor=color{red!20!green!20!blue!20},escapeinside=``, xleftmargin=2em,xrightmargin=2em, aboveskip=1em} 
    %lstset{language=perl,numbers=left,numberstyle=ttfamilyscriptsize,backgroundcolor=color{grey},frame=trbl,framesep=5pt,framexleftmargin=8mm,frameround=tttt,basicstyle=ttfamilysmall,keywordstyle=ttfamilybfcolor{Blue},ndkeywordstyle=ttfamilybfcolor{Brown},commentstyle=color{DarkGreen},identifierstyle=ttfamilycolor{black}bfseries,stringstyle=color{pink}ttfamily,showstringspaces=false,breaklines=true,escapeinside=``} 
     
    title{TITLE}
    author{AUTHOR} 
    date{today} 
    maketitle
     
    tableofcontents
    listoftables 
    listoffigures
     
    include{chapter1} 
    include{chapter2} 
    include{chapter3}
     
    end{document}
  • Makefile

  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    
    PDFC = xelatex
    READER = evince
     
    TARGET = manual.pdf
    OUTGROWTH = *.out *.log *.aux *.toc *.lof *.lot
    SOURCE = manual.tex
     
    $(TARGET): $(SOURCE)
    	$(PDFC)	$(SOURCE)
    	$(PDFC)	$(SOURCE)
     
    read:
    	$(READER) $(TARGET)
     
    clean:
    	-rm $(OUTGROWTH)
     
    cleanall:
    	-rm $(OUTGROWTH) $(TARGET)
     
    .PHONY:read clean cleanall