├── .DS_Store ├── logo.png ├── README.pdf ├── samples ├── .DS_Store └── eppdev-doc │ ├── .DS_Store │ ├── logo.png │ ├── eppdev-doc.pdf │ └── eppdev-doc.md ├── LICENSE-CN ├── LICENSE ├── shell └── pandoc_deploy.sh ├── README.md └── templates ├── eppdev.latex ├── eppdev-doc.latex └── eppdev-doc-mac.latex /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eppdev/eppdev-pandoc-template/HEAD/.DS_Store -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eppdev/eppdev-pandoc-template/HEAD/logo.png -------------------------------------------------------------------------------- /README.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eppdev/eppdev-pandoc-template/HEAD/README.pdf -------------------------------------------------------------------------------- /samples/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eppdev/eppdev-pandoc-template/HEAD/samples/.DS_Store -------------------------------------------------------------------------------- /samples/eppdev-doc/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eppdev/eppdev-pandoc-template/HEAD/samples/eppdev-doc/.DS_Store -------------------------------------------------------------------------------- /samples/eppdev-doc/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eppdev/eppdev-pandoc-template/HEAD/samples/eppdev-doc/logo.png -------------------------------------------------------------------------------- /samples/eppdev-doc/eppdev-doc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eppdev/eppdev-pandoc-template/HEAD/samples/eppdev-doc/eppdev-doc.pdf -------------------------------------------------------------------------------- /LICENSE-CN: -------------------------------------------------------------------------------- 1 | 版权所有(c)<2019><郝金隆> 2 | 3 | 反996许可证版本1.0 4 | 5 | 在符合下列条件的情况下,特此免费向任何得到本授权作品的副本(包括源代码、文件和/或相关内容,以下统称为“授权作品”) 6 | 的个人和法人实体授权:被授权个人或法人实体有权以任何目的处置授权作品,包括但不限于使用、复制,修改,衍生利用、散 7 | 布,发布和再许可: 8 | 9 | 10 | 1. 个人或法人实体必须在许可作品的每个再散布或衍生副本上包含以上版权声明和本许可证,不得自行修改。 11 | 2. 个人或法人实体必须严格遵守与个人实际所在地或个人出生地或归化地、或法人实体注册地或经营地(以较严格者为准) 12 | 的司法管辖区所有适用的与劳动和就业相关法律、法规、规则和标准。如果该司法管辖区没有此类法律、法规、规章和标准 13 | 或其法律、法规、规章和标准不可执行,则个人或法人实体必须遵守国际劳工标准的核心公约。 14 | 3. 个人或法人不得以任何方式诱导或强迫其全职或兼职员工或其独立承包人以口头或书面形式同意直接或间接限制、削弱或放弃 15 | 其所拥有的,受相关与劳动和就业有关的法律、法规、规则和标准保护的权利或补救措施,无论该等书面或口头协议是否被该 16 | 司法管辖区的法律所承认,该等个人或法人实体也不得以任何方法限制其雇员或独立承包人向版权持有人或监督许可证合规 17 | 情况的有关当局报告或投诉上述违反许可证的行为的权利。 18 | 19 | 该授权作品是"按原样"提供,不做任何明示或暗示的保证,包括但不限于对适销性、特定用途适用性和非侵权性的保证。在任何情况下, 20 | 无论是在合同诉讼、侵权诉讼或其他诉讼中,版权持有人均不承担因本软件或本软件的使用或其他交易而产生、引起或与之相关的任何索赔、 21 | 损害或其他责任。 22 | -------------------------------------------------------------------------------- /samples/eppdev-doc/eppdev-doc.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "XXX项目软件开发需求说明书" 3 | version: V0.2 4 | author: "jinlong.hao" 5 | date: "2019-08" 6 | company: EPPDEV.CN 7 | file-code: EPPDEV-TEMPLATE-SAMPLE-01 8 | logo: true 9 | lot: true 10 | lof: true 11 | history: 12 | - version: V0.1 13 | author: 郝金隆 14 | date: 2019-09-25 15 | desc: 创建第一份示例文档 16 | - version: V0.2 17 | author: 郝金隆 18 | date: 2019-09-26 19 | desc: 按照新的模板,增加了修订记录内容 20 | ... 21 | 22 | 23 | # 文档概述 24 | 25 | ## 本文说明 26 | 27 | 本文是markdown转换为pdf的示例文件[^1],主要用于演示如何通过markdown转换为pdf文件 28 | 29 | [^1]:测试脚注 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 | [百度](http://www.baidu.com) 66 | 67 | ## 列表 68 | 69 | ### 有编码列表 70 | 71 | 1. 列表 72 | 2. 列表 73 | 1. 列表 74 | 2. 列表 75 | 1. 列表 76 | 77 | ### 无编号列表 78 | 79 | * 编号 80 | * 编号 81 | * 编号 82 | * 编号 83 | * 编号 84 | * 编号 85 | 86 | ## 表格 87 | 88 | 89 | | 标题1 | 标题2 | 标题3 | 90 | | :-----: | :----- | -----: | 91 | | 1 | aaa | aaaaa | 92 | | 2 | bbb | bbbbb | 93 | 94 | :测试表格 95 | 96 | 97 | ## 图片 98 | 99 | ![测试图片(logo)](logo.png) 100 | 101 | 102 | 103 | ## 代码 104 | 105 | ~~~java 106 | public static void main(){ 107 | System.out.println("Hello, world!"); 108 | int a = 2; 109 | int b = a + 2; 110 | System.out.println(a > 2 ? 1 : 0); 111 | } 112 | ~~~ 113 | 114 | ~~~sql 115 | SELECT 116 | * 117 | FROM eppdev_tables 118 | WHERE name LIKE '%hell%' 119 | and id in ('aa', 'bbb') 120 | and create_time > '2019'; 121 | ~~~ 122 | 123 | ## 二级目录 124 | 125 | 正文 126 | 127 | ### 三级目录 128 | 129 | 正文 130 | 131 | #### 四级目录 #### 132 | 133 | () 134 | 135 | 正文 136 | 137 | ##### 五级目录 138 | 139 | 正文 140 | 141 | ##### level5 142 | 143 | pages 144 | 145 | 正文 146 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) <2019> 2 | 3 | Anti-996 License Version 1.0 (Draft) 4 | 5 | Permission is hereby granted to any individual or legal entity obtaining a copy 6 | of this licensed work (including the source code, documentation and/or related 7 | items, hereinafter collectively referred to as the "licensed work"), free of 8 | charge, to deal with the licensed work for any purpose, including without 9 | limitation, the rights to use, reproduce, modify, prepare derivative works of, 10 | publish, distribute and sublicense the licensed work, subject to the following 11 | conditions: 12 | 13 | 1. The individual or the legal entity must conspicuously display, without 14 | modification, this License on each redistributed or derivative copy of the 15 | Licensed Work. 16 | 17 | 2. The individual or the legal entity must strictly comply with all applicable 18 | laws, regulations, rules and standards of the jurisdiction relating to labor and 19 | employment where the individual is physically located or where the individual 20 | was born or naturalized; or where the legal entity is registered or is operating 21 | (whichever is stricter). In case that the jurisdiction has no such laws, 22 | regulations, rules and standards or its laws, regulations, rules and standards 23 | are unenforceable, the individual or the legal entity are required to comply 24 | with Core International Labor Standards. 25 | 26 | 3. The individual or the legal entity shall not induce or force its employee(s), 27 | whether full-time or part-time, or its independent contractor(s), in any 28 | methods, to agree in oral or written form, to directly or indirectly restrict, 29 | weaken or relinquish his or her rights or remedies under such laws, regulations, 30 | rules and standards relating to labor and employment as mentioned above, no 31 | matter whether such written or oral agreement are enforceable under the laws of 32 | the said jurisdiction, nor shall such individual or the legal entity limit, in 33 | any methods, the rights of its employee(s) or independent contractor(s) from 34 | reporting or complaining to the copyright holder or relevant authorities 35 | monitoring the compliance of the license about its violation(s) of the said 36 | license. 37 | 38 | THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 39 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 40 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT 41 | HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 42 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION 43 | WITH THE LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK. -------------------------------------------------------------------------------- /shell/pandoc_deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ##################################################### 4 | # 5 | # 本脚本是针对eppdev-pandoc-template实现自动将markdown文件 6 | # 生成pdf文件的处理脚本,可以配合gitlab-ci/jenkins等自动化 7 | # 构建工具使用,其中配置参数和输入项包括: 8 | # 1. 配置项target_path:所有生成pdf文件的根目录 9 | # 2. 输入参数:仅一个,针对某一个工程的子目录地址 10 | # 上述配置项和参数配合决定文件最终生成位置 11 | # 12 | # 文件版权所有:郝金隆(jinlong.hao@eppdev.cn), 2019 13 | # 许可:ANTI-996 License V1.0 14 | # 15 | # 整体处理流程: 16 | # 1. 遍历本目录,获取所有的markdown文件 17 | # 2. 在本目录的output目录和目标目录下创建同样的目录结构 18 | # 3. 获取当前时间戳,用于保存历史 19 | # 4. 依次对比已生成的pdf文件生成时间和markdown文件的最后 20 | # 修改时间,若有修改或未生成pdf文件,则生成pdf文件 21 | # 22 | # 环境依赖,对于要执行本脚本的环境,满足以下依赖条件: 23 | # 1. pandoc: 2.0以上 24 | # 2. texlive: 建议2017以上版本 25 | # 3. 安装eppdev-pandoc-template模板 26 | # 4. 安装template定义的字体(默认是msyh,msyhbd) 27 | # 28 | # ##################################################### 29 | 30 | # -------------------------------- 31 | # 0. 目录定义 32 | # -------------------------------- 33 | 34 | # 此处需要修改为目录地址 35 | target_path=/srv/doc/ 36 | 37 | # 输出的子目录地址 38 | target_folder_name=$1 39 | 40 | 41 | # ----------------------------------------------- 42 | # 1. 遍历本目录,获取所以的md文件 43 | # 获取当前目录 44 | # ----------------------------------------------- 45 | echo '任务01:获取所有的markdown文件及当前目录【开始】' 46 | 47 | file_list=`find ./ | grep \\.md$` 48 | cur_path=`pwd` 49 | 50 | # 错误判断 51 | if [[ $? -ne 0 ]]; then 52 | echo '任务01:获取所有的markdown文件及当前目录【失败】' 53 | exit 1 54 | else 55 | echo '任务01:获取所有的markdown文件及当前目录【成功】' 56 | fi 57 | 58 | # ----------------------------------------------- 59 | # 2. 遍历所有文件,在本目录和目标目录下创建目录 60 | # ----------------------------------------------- 61 | echo '任务02:创建目标目录结构【开始】' 62 | for file in $file_list 63 | do 64 | # 获取相对目录结构 65 | file_path=${file%/*} 66 | 67 | # 创建本工程内的目录 68 | mkdir -pv output/$file_path 69 | mkdir -pv $target_path/$target_folder_name/$file_path 70 | mkdir -pv $target_path/$target_folder_name/_his/$file_path 71 | done 72 | 73 | # 错误判断 74 | if [[ $? -ne 0 ]]; then 75 | echo '任务02: 创建目标目录结构【失败】' 76 | exit 1 77 | else 78 | echo '任务02: 创建目标目录结构【成功】' 79 | fi 80 | 81 | # ----------------------------------------------- 82 | # 3. 获取当前的时间戳 83 | # ----------------------------------------------- 84 | echo '任务03:获取当前时间戳【开始】' 85 | datetime_str=`date +'%Y%m%d_%H%M%S'` 86 | date_str=`date +'%Y%m%d'` 87 | 88 | # 错误判断 89 | if [[ $? -ne 0 ]]; then 90 | echo '任务03: 获取当前时间戳【失败】' 91 | exit 1 92 | else 93 | echo '任务03: 获取当前时间戳【成功】' 94 | fi 95 | 96 | 97 | # ----------------------------------------------- 98 | # 4. 依次判断md和pdf文件的修改时间,有更新则重新生成pdf文件 99 | # 100 | # 注意:git时间需要通过git log获取,避免gitlab-ci更新修改时间 101 | # ----------------------------------------------- 102 | echo '任务04:生成pdf文件【开始】' 103 | for file in $file_list 104 | do 105 | # 获取文件名 106 | file_name=${file%.*} 107 | file_path=${file%/*} 108 | target_pdf_file=$target_path/$target_folder_name/${file_name}.pdf 109 | target_pdf_his_file=$target_path/$target_folder_name/_his/${file_name}_${date_str}.pdf 110 | 111 | 112 | # 获取md文件修改时间戳 113 | md_dt_str=`git log --date=raw ${file} | grep Date | head -1` 114 | md_dt=`echo $md_dt_str | awk -F ' ' '{print $2}'` 115 | 116 | 117 | # 切换目录 118 | cd $file_path 119 | 120 | if [ ! -f "$target_pdf_file" ]; then 121 | echo "任务04:生成pdf文件,创建$target_pdf_file" 122 | pandoc --pdf-engine=xelatex --template=eppdev-doc --listings $cur_path/${file} -o ${target_pdf_file} 123 | cp ${target_pdf_file} ${target_pdf_his_file} 124 | else 125 | # 获取pdf的时间戳 126 | pdf_dt=`date +%s -r ${target_pdf_file}` 127 | 128 | if [ $md_dt -gt $pdf_dt ]; then 129 | echo "任务04:生成pdf文件,创建$target_pdf_file" 130 | pandoc --pdf-engine=xelatex --template=eppdev-doc --listings $cur_path/${file} -o ${target_pdf_file} 131 | cp ${target_pdf_file} ${target_pdf_his_file} 132 | fi 133 | fi 134 | 135 | # 回到根目录 136 | cd $cur_path 137 | done 138 | 139 | 140 | # 错误判断 141 | if [[ $? -ne 0 ]]; then 142 | echo '任务04: 生成pdf文件【失败】' 143 | exit 1 144 | else 145 | echo '任务04: 生成pdf文件【成功】' 146 | fi 147 | 148 | 149 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: EPPDEV-PANDOC-TEMPLATE使用指南 3 | version: V1.3 4 | author: 郝金隆 5 | date: 2019-09 6 | file-code: EPPDEV-PANDOC-TEMPLATE-USAGE 7 | header-right: 2019-09 8 | logo: true 9 | history: 10 | - version: V1.0 11 | author: 郝金隆 12 | date: 2019-09-25 13 | desc: 14 | - 1. 创建文档 15 | - 2. 完成第一版的文档说明 16 | - version: V1.1 17 | author: 郝金隆 18 | date: 2019-09-26 19 | desc: 增加了修订目录相关内容 20 | - version: V1.2 21 | author: 郝金隆 22 | date: 2019-09-28 23 | desc: 24 | - 1.修改一级目录引导线的格式,增加点间距 25 | - 2.修改修订目录的格式,去掉内容空行,标题粗体 26 | - version: V1.3 27 | author: 郝金隆 28 | date: 2019-10-13 29 | desc: 30 | - 1.增加了与DevOps的自动化处理脚本 31 | - 2.增加了与DevOps集成的环境配置说明 32 | ... 33 | 34 | 35 | # 工程说明 36 | 37 | 本工程是个人根据实际需要参考相关网络文档,整理的通过pandoc转换为pdf的模板, 38 | 用于实现内部IT项目管理文档格式的标准化工作。 39 | 40 | 41 | # 基础环境配置 42 | 43 | markdown生成pdf主要需要使用Pandoc和Latex(texlive/miktex)两个工具,具体安装方式如下: 44 | 45 | ## Pandoc的安装 46 | 47 | Pandoc是由John MacFarlane开发的标记语言转换工具,可实现不同标记语言间的格式转换, 48 | 堪称该领域中的“瑞士军刀”。Pandoc使用Haskell语言编写,以命令行形式实现与用户的交互, 49 | 可支持多种操作系统。 50 | 51 | * Window下的安装:下载[安装包](https://github.com/jgm/pandoc/releases)直接安装即可 52 | * Linux/FreeBSD下的安装:Pandoc已经包含在大部分Linux发行版的官方仓库中, 53 | 直接使用诸如apt/dnf/yum/pacman之类的安装工具直接安装即可 54 | * MacOS下的安装:建议通过HomeBrew进行安装即可 55 | 56 | > 详细的安装说明参见:[官方安装文档](https://pandoc.org/installing.html) 57 | 58 | ## Latex的安装 59 | 60 | latex工具,在windows下建议安装miktex,Linux和MacOS下建议安装texlive 61 | 62 | * Windows下的安装:下载安装[miktex](https://miktex.org/download), 63 | 注意安装后需要再安装cjk,cjk-fonts等相关package 64 | * Linux/FreeBSD下的安装:使用apt/dnf/yum/pacman/pkg等安装工具安装 65 | texlive、texlive-latex等相关软件包即 66 | * MacOS下的安装:使用HomeBrew安装texlive即可 67 | 68 | 69 | # 安装后的设置 70 | 71 | ## 配置Pandoc模板 72 | 73 | 为保证生成的pdf格式(自动插入封面、目录页、页眉页脚等信息),在本地环境中安装模板,具体步骤是: 74 | 75 | * 下载[eppdev-pandoc-template模板](https://github.com/eppdev/eppdev-pandoc-template/releases) 76 | 将其保存到本地 77 | * 根据需要对模板进行相应的定制,具体定制方式参见下节 78 | * 将修改后的模板文件复制到指定目录下[^filename] 79 | * Window下:C:/Users/USERNAME/AppDatax/Roaming/pandoc/templates 80 | * Linux/FreeBSD/MacOS:~/.pandoc/templates/ 81 | 82 | [^filename]: 如有不同需要,可以定制不同的模板,作不同的命名,复制到对应目录下 83 | 84 | ## 模板的定制 85 | 86 | 模板定制主要修改模板最前面的"〇、模板基础配置"相关内容,主要可修改的包括: 87 | 88 | 1. 公司和组织,目前默认是"EPPDEV.CN" 89 | 2. 正文缩进,目前默认是2em(2个中文字符,4个英文字符) 90 | 3. 主要中文字体和英文字体:目前都是微软雅黑 91 | 4. 页眉、页脚展示内容,目前是: 92 | 1. 左页眉:title 93 | 2. 右页眉:"企业机密,请勿外传" 94 | 3. 作页脚:company 95 | 4. 右页脚:页码 96 | 97 | > eisvogel模板原来右页眉默认是date,如需恢复为data, 98 | 只需要将"EPPDEV.CN"改为$date$即可 99 | 100 | 101 | 现有内容如下: 102 | 103 | ~~~latex 104 | 105 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 106 | % 107 | % 〇、模板基础配置 108 | % 109 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 110 | 111 | % 公司和组织 112 | \newcommand*{\company}{$if(company)$$company$$else$EPPDEV.CN$endif$} 113 | 114 | % 缩进 115 | \newcommand*{\udfparindent}{2em} 116 | 117 | % 主要中文字体 118 | \newcommand*{\thecjkmainfont}{$if(CJKmainfont)$$CJKmainfont$$else$Microsoft YaHei$endif$} 119 | 120 | % 主要英文字体 121 | \newcommand*{\themainfont}{$if(mainfont)$$mainfont$$else$Microsoft YaHei$endif$} 122 | 123 | % logo 124 | \newcommand*{\thelogo}{$if(logo-url)$$logo-url$$else$logo.png$endif$} 125 | 126 | % 页眉-左 127 | \newcommand*{\headerleft}{$if(header-left)$$header-left$$else$$title$$endif$} 128 | 129 | % 页眉-右 130 | \newcommand*{\headerright}{$if(header-right)$$header-right$$else$企业机密,请勿外传$endif$} 131 | 132 | % 页脚-左 133 | \newcommand*{\footerleft}{$if(footer-left)$$footer-left$$else$\company$endif$} 134 | 135 | % 页脚-右 136 | \newcommand*{\footerright}{\thepage} 137 | 138 | ~~~ 139 | 140 | 141 | ## 字体设置 142 | 143 | 目前页面默认的字体是微软雅黑,对于非Windows系统,可能不存在该字体,则有以下两种解决方案: 144 | 145 | 1. 手工安装微软雅黑字体(需要msyh,msyhbd两个文件) 146 | 2. 修改为其他字体,如苹方、文泉驿等 147 | 148 | 若需要多个团队共同使用,建议采用方案一。 149 | 150 | 151 | # pdf文件的生成 152 | 153 | ## PDF文件指定metadata信息 154 | 155 | 在每个markdown最前面增加以下主要metadata信息,metadata内容开始行内容为三个“-”,结束行为三个“.”,示例如下: 156 | 157 | ~~~yml 158 | title: EPPDEV-PANDOC-TEMPLATE使用指南 159 | version: 1.0 160 | author: 郝金隆 161 | date: 2019-09 162 | file-code: EPPDEV-PANDOC-TEMPLATE-USAGE 163 | history: 164 | - version: V1.0 165 | author: 郝金隆 166 | date: 2019-09-25 167 | desc: 168 | - 1. 创建文档 169 | - 2. 完成第一版的文档说明 170 | - version: V1.1 171 | author: 郝金隆 172 | date: 2019-09-26 173 | desc: 增加了修订目录相关内容 174 | ~~~ 175 | 176 | 其他可选配置项目如下: 177 | 178 | 1. subtitle: 副标题 179 | 2. header-left: 左页眉 180 | 3. header-right: 右页眉 181 | 4. footer-left: 左页脚 182 | 5. footer-right: 右页脚 183 | 6. company: 公司名称 184 | 7. CJKmainfont: 主要中文字体 185 | 8. mainfont: 主要字体 186 | 9. lot: 是否创建表格目录 187 | 10. lof: 是否创建图片目录 188 | 11. logo: 是否在封面显示logo(需要在markdown相同文件夹下有logo.png文件) 189 | 190 | > 可选配置项中,建议除了subtitle外,全部在模板中定制,不在markdown文件中定制 191 | 192 | ## Markdown其他编写要求 193 | 194 | pandoc默认使用的[pandoc_markdown](https://pandoc.org/MANUAL.html#pandocs-markdown)格式, 195 | 为避免markdown转pdf格式异常,在编写markdown的时候有几个原则要求: 196 | 197 | * 每个标题前后都必须有空行 198 | * 每个表格前后都必须有空行 199 | * 每个代码块前后收必须有空行 200 | * 每个列表前后必须有空行 201 | 202 | > 总而言之,每个不同的格式和内容前后都需要有空行,详细内容参见 203 | > [pandoc官方文档](https://pandoc.org/MANUAL.html#pandocs-markdown) 204 | 205 | 206 | ## 文件生成 207 | 208 | 配置完成后即可在通过pandoc命令生成pdf文件: 209 | 210 | ~~~shell 211 | pandoc --listings --pdf-engine=xelatex --template eppdev-doc a.md -o a.pdf 212 | ~~~ 213 | 214 | > 若定制的模板修改了文件名,需要将命令中的eppdev-doc修改为修改后的文件名 215 | 216 | 217 | # 与DevOps集成 218 | 219 | 本pandoc模板可以很容易的与gitlib-ci等devops工具相集成,实现pdf文件的自动生成, 220 | 这样就无需每个人都安装一套pandoc, texlive等环境,下文以gitlab为例,说明如何 221 | 与DevOps进行集成 222 | 223 | ## 发布与编译环境准备 224 | 225 | 首先需要再DevOps的执行节点进行环境配置[^executor],要配置的环境包括: 226 | 227 | [^executor]: 是指具体进行编译执行的环境,如gitlab-ci中的gitlab-runner所在的服务器 228 | 229 | ### 安装Pandoc 230 | 231 | 安装方式可参考上文,注意很多服务器操作系统(如CentOS)官方库的pandoc还是1.x版本, 232 | 使用该版本将不支持修订目录功能,建议手工安装最新的pandoc,具体可以通过官网下载 233 | 最新版本,解压缩以后,设置PATH环境变量即可 234 | 235 | ### 安装TexLive 236 | 237 | 安装方式同样可以参考上文,但是服务器操作系统版本一般相对比较第,建议手工安装最新 238 | 版本,可以从国内镜像如[华为](https://mirrors.huaweicloud.com/CTAN/systems/texlive/Images/)、 239 | [清华](https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/Images/)等站点下载 240 | 最新的iso文件,当前最新为2019。具体安装命令如下: 241 | 242 | ~~~shell 243 | wget https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/Images/texlive2019.iso 244 | sudo mount ./texlive2019.iso /mnt 245 | cd /mnt 246 | sudo ./install_tl 247 | ~~~ 248 | 249 | 安装完成后,需要将修改环境变量,将最新的texlive目录下的bin目录添加到环境变量中 250 | 251 | ### 安装template文件 252 | 253 | 根据需要,将eppdev_doc.latex文件复制到进行编译执行的服务器用户主目录(如gitlab-ci对应的 254 | /home/gitlab-runner)下的.pandoc/templates目录下 255 | 256 | ### 安装字体 257 | 258 | 具体需安装的字体根据eppdev_doc.latex中的配置为准,本文以微软雅黑为例。将msyh.ttf, 259 | msyhbd.ttf两个文件上传到服务器上,然后进行安装: 260 | 261 | ~~~shell 262 | sudo mkdir /usr/share/fonts/chinese 263 | sudo cp msyh*.ttf /usr/share/fonts/chinese 264 | cd /usr/share/fonts/chinese 265 | sudo mkfontsdir 266 | sudo mkfontscale 267 | ~~~ 268 | 269 | ### 配置目标目录 270 | 271 | 创建一个要发布的目标文档目录,提供编译执行者可读写的权限,以gitlab为例: 272 | 273 | ~~~shell 274 | sudo mkdir /srv/doc 275 | sudo chown gitlab-runner /srv/doc 276 | ~~~ 277 | 278 | > 配置好目录以后后续即可通过nginx/httpd的文件列表功能,或者通过rsync同步 279 | > 到对应的文件管理服务器中,本文对此就不再赘述 280 | 281 | ### 安装pandoc_deploy.sh 282 | 283 | 将工程下载的pandoc_deploy.sh文件进行修改,将target_dir修改为上文创建的目标目录。 284 | 然后将其复制到/usr/bin目录下,并为其添加可执行权限 285 | 286 | ~~~shell 287 | chmod a+x pandoc_deploy.sh 288 | sudo cp pandoc_deploy.sh /usr/bin/ 289 | ~~~ 290 | 291 | ## DevOps的配置 292 | 293 | ### 主要配置方式 294 | 295 | 环境安装好了以后,即可在DevOps的环境中定义任务,完成自动的pdf生成工作,具体是的调用命令为: 296 | 297 | ~~~shell 298 | /usr/bin/pandoc_deploy.sh 本工程对应的目录 299 | ~~~ 300 | 301 | > 注意:此处的目录为针对本工程的代码对应的所有目录 302 | 303 | 304 | ### gitlab-ci配置说明 305 | 306 | 在仓库主目录下创建.gitlab-ci.yml文件,示例内容如下: 307 | 308 | ~~~yml 309 | stages: 310 | - deploy 311 | 312 | 313 | doc-deploy: 314 | stage: deploy 315 | script: 316 | - /usr/bin/pandoc_deploy.sh tmp_doc 317 | tags: 318 | - pandoc 319 | ~~~ 320 | 321 | 上述配置主要说明如下: 322 | 323 | 1. stages: deploy, 是指本工程编译只有一个stage 324 | 2. doc-deploy: 是指定义的一个任务,其所属的stage为deploy 325 | 3. /usr/bin/pandoc_deploy.sh tmp_doc 是指本工程生成的pdf将复制到/srv/doc/tmp_doc目录下[^dir] 326 | 4. tags:pandoc, 是因为环境中有多个gitlab-runner,仅有该标签的runner配置了pandoc环境 327 | 328 | [^dir]: 之所以是这个目录是因为pandoc_deploy.sh中的target_dir为/srv/doc 329 | 330 | 331 | ## 下一步的定制 332 | 333 | 可以根据需要对pandoc_deploy.sh进行修改,通过rsync将其与其他文档管理系统进行同步。 334 | 当然,若只是简单的通过httpd或者nginx进行文件展示,则该文件无需修改, 335 | 但是注意至少需要通过htpasswd进行权限验证,以避免企业机密的外泄! 336 | 337 | 338 | # 引用参考 339 | 340 | 本工程主要参考包括: 341 | 342 | * [Eisvogel模板](https://github.com/Wandmalfarbe/pandoc-latex-template): 343 | 参考Eisvogel模板,针对国内环境的需要,做了个性化定制,主要取便在于 344 | * 指定了字体为微软雅黑,默认解决中文问题 345 | * 指定目录编号层级为5级 346 | * 解决了4、5级目录的格式问题,确保目录后有换行 347 | * 定制了页眉页脚内容 348 | * 增加了version属性,展示在封面上 349 | * 增加了file-code文档编号属性,用于在封面上的展示 350 | * 增加了company可选(默认在模板中设置,可以手工修改)属性,展示在封面和页脚上 351 | * 修改了页码格式 352 | * ... 353 | * [formal-boot-title-page](https://www.latextemplates.com/template/formal-book-title-page): 354 | 参考该模板修改了封面格式,主要修改点 355 | * 增加文档编号 356 | * 调整了author的展示 357 | * publisher改为company 358 | * 日期调整到company下 359 | 360 | # 许可 361 | 362 | 版权所有:2019,[郝金隆](mailto:jinlong.hao@eppdev.cn) 363 | 364 | 软件许可:[ANTI-996 License v1.0](https://github.com/eppdev/eppdev-pandoc-template/blob/master/LICENSE-CN) 365 | 366 | 367 | # 附录 368 | 369 | ## Markdown概述 370 | 371 | Markdown是一种轻量级标记语言,创始人为约翰·格鲁伯(英语:John Gruber)。 372 | 它允许人们“使用易读易写的纯文本格式编写文档,然后转换成有效的XHTML(或者HTML)文档”。 373 | 这种语言吸收了很多在电子邮件中已有的纯文本标记的特性。 374 | 375 | 由于Markdown的轻量化、易读易写特性,并且对于图片,图表、数学式都有支持, 376 | 当前许多网站都广泛使用 Markdown 来撰写帮助文档或是用于论坛上发表消息。 377 | 例如:GitHub、reddit、Diaspora、Stack Exchange、OpenStreetMap 、SourceForge等。 378 | 甚至Markdown能被使用来撰写电子书。 379 | 380 | Markdown语法参见:[Markdown语法介绍(coding)](https://coding.net/help/doc/project/markdown.html)、 381 | [Markdown基础介绍(简书)](https://www.jianshu.com/p/191d1e21f7ed) 382 | 383 | 384 | ## Markdown写作环境说明 385 | 386 | Markdown的规范本身就是文本文档,故任何文本文件编辑器均可进行markdown文件的编辑,编辑markdown文件可以使用专业的编辑器,也可以在IDE环境中安装markdown的插件。 387 | 388 | 目前业内常用的markdown文件编辑器主要包括: 389 | 390 | * sublime 391 | * remarkable 392 | * markdownpad 393 | * Typora 394 | 395 | 396 | IDE环境: 397 | 398 | * Intellij IDEA:可以安装[markdown-navigator](https://plugins.jetbrains.com/plugin/7896-markdown-navigator)插件 399 | 或者[markdown](https://plugins.jetbrains.com/plugin/7793-markdown)插件 400 | * Eclipse: 可以安装[markdown-text-editor](https://marketplace.eclipse.org/content/markdown-text-editor)插件 401 | * VSCode: 可以安装[markdown](https://code.visualstudio.com/docs/languages/markdown)插件 402 | 403 | ## 配置http环境的安全认证 404 | 405 | 以CentOS环境下的nginx为例 406 | 407 | ### 首先安装httpd-tools: 408 | 409 | ~~~shell 410 | sudo yum install httpd-tools 411 | ~~~ 412 | 413 | ### 然后创建密码文件 414 | 415 | ~~~shell 416 | sudo mkdir /etc/nginx/pass 417 | sudo htpasswd -cb /etc/nginx/pass/mypass eppdev 123 418 | ~~~ 419 | 420 | > 上述命令的作用是在该目录下创建一个mypass文件,用户名是eppdev, 421 | > 密码是123 422 | 423 | ### 修改nginx配置 424 | 425 | 在/etc/nginx/nginx.conf文件中添加以下配置 426 | 427 | ~~~ 428 | location /doc/ { 429 | alias /srv/doc/ ; 430 | auth_basic "Input Password:"; 431 | auth_basic_user_file "/etc/nginx/pass/mypass"; 432 | autoindex on; 433 | autoindex_exact_size off; 434 | autoindex_localtime on; 435 | } 436 | ~~~ 437 | 438 | 上述代码的说明: 439 | 440 | 1. 前两行是指创建一个虚拟的链接子目录,映射到/srv/doc/目录下,即访问 441 | http://host:port/doc/即为对应的/srv/doc目录 442 | 2. 第3,4行是指使用的是基础的认证机制,认证文件即为上文创建的密码文件 443 | 3. 第5,6,7行是指启动文件夹文件索引功能,直接通过链接可以访问目录下的文件 444 | 445 | 446 | -------------------------------------------------------------------------------- /templates/eppdev.latex: -------------------------------------------------------------------------------- 1 | % %%%%%%%%%%%%%%%%% 2 | % 3 | % This is the eppdev letax template, used to generate pdf 4 | % file from markdown 5 | % 6 | % Copyrigh jinlong.hao 2019, ALL right preserved! 7 | % 8 | % Licensed by Anti-996 License V1.0 9 | % 10 | % %% 11 | 12 | 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | % 15 | % 〇、模板基础配置 16 | % 17 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18 | 19 | % 公司和组织 20 | \newcommand*{\company}{$if(company)$$company$$else$EPPDEV.CN$endif$} 21 | 22 | % 缩进 23 | \newcommand*{\udfparindent}{2em} 24 | 25 | % 主要中文字体 26 | \newcommand*{\thecjkmainfont}{$if(CJKmainfont)$$CJKmainfont$$else$Microsoft YaHei$endif$} 27 | 28 | % 主要英文字体 29 | \newcommand*{\themainfont}{$if(mainfont)$$mainfont$$else$Microsoft YaHei$endif$} 30 | 31 | % logo 32 | \newcommand*{\thelogo}{$if(logo-url)$$logo-url$$else$logo.png$endif$} 33 | 34 | % 页眉-左 35 | \newcommand*{\headerleft}{$if(header-left)$$header-left$$else$$title$$endif$} 36 | 37 | % 页眉-右 38 | \newcommand*{\headerright}{$if(header-right)$$header-right$$else$企业机密,请勿外传$endif$} 39 | 40 | % 页脚-左 41 | \newcommand*{\footerleft}{$if(footer-left)$$footer-left$$else$\company$endif$} 42 | 43 | % 页脚-右 44 | \newcommand*{\footerright}{\thepage} 45 | 46 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47 | % 48 | % 一、文档基础配置 49 | % 1.1 文档类型 50 | % 1.2 段落、字体及缩进设置 51 | % 1.3 颜色设置 52 | % 1.4 目录设置 53 | % 1.5 页眉页脚 54 | % 1.6 代码块listing设置 55 | % 1.7 图片设置 56 | % 1.8 引用quote设置 57 | % 1.9 注释captions设置 58 | % 1.10 表格table样式设置 59 | % 60 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 61 | 62 | % ----------------------------------- 63 | % 1.1 文档类型 64 | % ----------------------------------- 65 | \PassOptionsToPackage{unicode}{hyperref} 66 | \PassOptionsToPackage{hyphens}{url} 67 | \PassOptionsToPackage{dvipsnames,svgnames*,x11names*,table}{xcolor} 68 | \documentclass[ 69 | $if(fontsize)$ 70 | $fontsize$, 71 | $endif$ 72 | a4paper 73 | ]{scrartcl} 74 | 75 | \usepackage{longtable,booktabs} 76 | \usepackage{framed} 77 | \usepackage{listings} 78 | \usepackage{graphicx,grffile} 79 | \usepackage{titletoc} 80 | 81 | 82 | % ---------------------------------- 83 | % 1.2 段落、字体及缩进设置 84 | % ---------------------------------- 85 | \usepackage{lmodern} 86 | \usepackage{setspace} 87 | 88 | % 1.2倍行距 89 | \setstretch{1.2} 90 | \usepackage{amssymb,amsmath} 91 | 92 | % 字体设置 93 | \usepackage{ifxetex,ifluatex} 94 | \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex 95 | \usepackage[T1]{fontenc} 96 | \usepackage[utf8]{inputenc} 97 | \usepackage{textcomp} % provide euro and other symbols 98 | \else % if luatex or xetex 99 | \usepackage{unicode-math} 100 | \defaultfontfeatures{Scale=MatchLowercase} 101 | \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} 102 | \setmainfont{\themainfont} 103 | \ifxetex 104 | \usepackage{xeCJK} 105 | \setCJKmainfont{\thecjkmainfont} 106 | \setCJKsansfont{\thecjkmainfont} 107 | \fi 108 | \ifluatex 109 | \usepackage[]{luatexja-fontspec} 110 | \setmainjfont{\thecjkmainfont} 111 | \setCJKsansfont{\thecjkmainfont} 112 | \fi 113 | \fi 114 | 115 | % 缩进 116 | \usepackage{indentfirst} 117 | \setlength{\parindent}{\udfparindent} 118 | 119 | % 页边距 120 | \usepackage[margin=2.5cm,includehead=true,includefoot=true,centering]{geometry} 121 | 122 | % ------------------------------------------- 123 | % 1.3 颜色配置 124 | % ------------------------------------------- 125 | 126 | % 颜色 127 | \usepackage{color} 128 | \usepackage{xcolor} 129 | \definecolor{default-linkcolor}{HTML}{100000} 130 | \definecolor{default-filecolor}{HTML}{100000} 131 | \definecolor{default-citecolor}{HTML}{101010} 132 | \definecolor{default-urlcolor}{HTML}{4077C0} 133 | \usepackage{hyperref} 134 | \hypersetup{ 135 | pdftitle={$title$}, 136 | pdfauthor={EPPDEV}, 137 | colorlinks=true, 138 | linkcolor=$if(linkcolor)$$linkcolor$$else$default-linkcolor$endif$, 139 | filecolor=$if(filecolor)$$filecolor$$else$default-filecolor$endif$, 140 | citecolor=$if(citecolor)$$citecolor$$else$default-citecolor$endif$, 141 | urlcolor=$if(urlcolor)$$urlcolor$$else$default-urlcolor$endif$, 142 | breaklinks=true, 143 | pdfcreator={latex via pandoc with eppdev-pandoc-template}} 144 | \urlstyle{same} % disable monospaced font for URLs 145 | $if(strikeout)$ 146 | \usepackage[normalem]{ulem} 147 | % Avoid problems with \sout in headers with hyperref 148 | \pdfstringdefDisableCommands{\renewcommand{\sout}{}} 149 | $endif$ 150 | \providecommand{\tightlist}{% 151 | \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} 152 | 153 | 154 | 155 | % ------------------------------------------ 156 | % 1.4 目录设置 157 | % ------------------------------------------ 158 | 159 | % 目录层级 160 | \setcounter{secnumdepth}{5} 161 | 162 | % paragraph和subparagraph当作目录来处理 163 | \ifx\paragraph\undefined\else 164 | \let\oldparagraph\paragraph 165 | \renewcommand{\paragraph}[1]{ 166 | \setlength{\parindent}{0em} 167 | \oldparagraph{#1}\mbox{} 168 | \setlength{\parindent}{\udfparindent} 169 | } 170 | \fi 171 | \ifx\subparagraph\undefined\else 172 | \let\oldsubparagraph\subparagraph 173 | \renewcommand{\subparagraph}[1]{ 174 | \setlength{\parindent}{0em} 175 | \noindent\oldsubparagraph{#1}\mbox{} 176 | \setlength{\parindent}{\udfparindent} 177 | } 178 | \fi 179 | 180 | % ------------------------------------------- 181 | % 1.5 页眉页脚 182 | % ------------------------------------------- 183 | \usepackage{fancyhdr} 184 | 185 | \fancypagestyle{eppdev-header-footer}{ 186 | \fancyhead{} 187 | \fancyfoot{} 188 | \lhead[\headerright]{\headerleft} 189 | \chead[]{} 190 | \rhead[\headerleft]{\headerright} 191 | \lfoot[\footerright]{\footerleft} 192 | \cfoot[]{} 193 | \rfoot[\footerleft]{\footerright} 194 | \renewcommand{\headrulewidth}{0.4pt} 195 | \renewcommand{\footrulewidth}{0.4pt} 196 | } 197 | \pagestyle{eppdev-header-footer} 198 | 199 | 200 | % ---------------------------------------- 201 | % 1.6 listing设置 202 | % ---------------------------------------- 203 | \usepackage{listings} 204 | \newcommand{\passthrough}[1]{#1} 205 | \lstset{defaultdialect=[5.3]Lua} 206 | \lstset{defaultdialect=[x86masm]Assembler} 207 | 208 | $if(highlighting-macros)$ 209 | $highlighting-macros$ 210 | $endif$ 211 | 212 | 213 | % 基础颜色 214 | \definecolor{listing-background}{HTML}{F7F7F7} 215 | \definecolor{listing-rule}{HTML}{B3B2B3} 216 | \definecolor{listing-numbers}{HTML}{B3B2B3} 217 | \definecolor{listing-text-color}{HTML}{000000} 218 | \definecolor{listing-keyword}{HTML}{435489} 219 | \definecolor{listing-identifier}{HTML}{435489} 220 | \definecolor{listing-string}{HTML}{00999A} 221 | \definecolor{listing-comment}{HTML}{8E8E8E} 222 | \definecolor{listing-javadoc-comment}{HTML}{006CA9} 223 | 224 | % java 颜色 225 | \lstdefinestyle{eppdev-listing-style}{ 226 | language = java, 227 | numbers = left, 228 | xleftmargin = 2.7em, 229 | framexleftmargin = 2.5em, 230 | backgroundcolor = \color{listing-background}, 231 | basicstyle = \color{listing-text-color}\small\ttfamily{}\linespread{1.15}, % print whole listing small 232 | breaklines = true, 233 | frame = single, 234 | framesep = 0.19em, 235 | rulecolor = \color{listing-rule}, 236 | frameround = ffff, 237 | tabsize = 4, 238 | numberstyle = \color{listing-numbers}, 239 | aboveskip = 1.0em, 240 | belowskip = 0.1em, 241 | abovecaptionskip = 0em, 242 | belowcaptionskip = 1.0em, 243 | keywordstyle = \color{listing-keyword}\bfseries, 244 | classoffset = 0, 245 | sensitive = true, 246 | identifierstyle = \color{listing-identifier}, 247 | commentstyle = \color{listing-comment}, 248 | morecomment = [s][\color{listing-javadoc-comment}]{/**}{*/}, 249 | stringstyle = \color{listing-string}, 250 | showstringspaces = false, 251 | escapeinside = {/*@}{@*/}, % Allow LaTeX inside these special comments 252 | literate = 253 | {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1 254 | {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1 255 | {à}{{\`a}}1 {è}{{\'e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1 256 | {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1 257 | {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1 258 | {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1 259 | {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1 260 | {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1 261 | {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1 262 | {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1 263 | {€}{{\EUR}}1 {£}{{\pounds}}1 {«}{{\guillemotleft}}1 264 | {»}{{\guillemotright}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?`}}1 265 | {…}{{\ldots}}1 {≥}{{>=}}1 {≤}{{<=}}1 {„}{{\glqq}}1 {“}{{\grqq}}1 266 | {”}{{''}}1 267 | } 268 | \lstset{style=eppdev-listing-style} 269 | 270 | \lstdefinelanguage{XML}{ 271 | morestring = [b]", 272 | moredelim = [s][\bfseries\color{listing-keyword}]{<}{\ }, 273 | moredelim = [s][\bfseries\color{listing-keyword}]{}, 274 | moredelim = [l][\bfseries\color{listing-keyword}]{/>}, 275 | moredelim = [l][\bfseries\color{listing-keyword}]{>}, 276 | morecomment = [s]{}, 277 | morecomment = [s]{}, 278 | commentstyle = \color{listing-comment}, 279 | stringstyle = \color{listing-string}, 280 | identifierstyle = \color{listing-identifier} 281 | } 282 | 283 | 284 | 285 | 286 | % -------------------------------------------- 287 | % 1.7 图片设置 288 | % -------------------------------------------- 289 | 290 | % 设置图片的大小 291 | $if(graphics)$ 292 | \usepackage{graphicx,grffile} 293 | \makeatletter 294 | \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} 295 | \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi} 296 | \makeatother 297 | \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} 298 | $endif$ 299 | 300 | 301 | \usepackage{graphicx,grffile} 302 | \usepackage[export]{adjustbox} 303 | 304 | 305 | % 设置图片不要缩进 306 | \ifx\includegraphics\undefined\else 307 | \let\oldincludegraphics\includegraphics 308 | \renewcommand{\includegraphics}[1]{ 309 | \vskip 8pt 310 | \setlength{\parindent}{0em} 311 | \oldincludegraphics{#1} 312 | \setlength{\parindent}{\udfparindent} 313 | \vskip 2pt 314 | } 315 | \fi 316 | 317 | % figure不浮动 318 | \usepackage{float} 319 | \floatplacement{figure}{H} 320 | 321 | 322 | % ------------------------------------------- 323 | % 1.8 引用的格式 324 | % ------------------------------------------- 325 | \definecolor{blockquote-border}{RGB}{221,221,221} 326 | \definecolor{blockquote-text}{RGB}{119,119,119} 327 | \usepackage{mdframed} 328 | \newmdenv[rightline=false,bottomline=false,topline=false,linewidth=3pt,linecolor=blockquote-border,skipabove=\parskip]{customblockquote} 329 | \renewenvironment{quote}{\vskip 8pt \small \begin{customblockquote}\list{}{\rightmargin=0em\leftmargin=0em}% 330 | \item\relax\color{blockquote-text}\ignorespaces}{\unskip\unskip\endlist\end{customblockquote}} 331 | 332 | % -------------------------------------------- 333 | % 1.9 Captions的格式 334 | % -------------------------------------------- 335 | \definecolor{caption-color}{HTML}{777777} 336 | \usepackage[font={scriptsize}]{caption} 337 | \setcapindent{0em} 338 | \captionsetup[figure]{labelfont={bf},labelformat={default},labelsep=period,name={图}} 339 | \captionsetup[table]{labelfont={bf},labelformat={default},labelsep=period,name={表}} 340 | 341 | 342 | 343 | % -------------------------------------------- 344 | % 1.10 表格样式设置 345 | % -------------------------------------------- 346 | \usepackage{longtable} 347 | \definecolor{table-row-color}{HTML}{EFEFEF} 348 | \definecolor{table-rule-color}{HTML}{999999} 349 | 350 | %\arrayrulecolor{black!40} 351 | \arrayrulecolor{table-rule-color} % color of \toprule, \midrule, \bottomrule 352 | \setlength\heavyrulewidth{0.3ex} % thickness of \toprule, \bottomrule 353 | \renewcommand{\arraystretch}{1.3} % spacing (padding) 354 | 355 | % Reset rownum counter so that each table 356 | % starts with the same row colors. 357 | % https://tex.stackexchange.com/questions/170637/restarting-rowcolors 358 | \let\oldlongtable\longtable 359 | \let\endoldlongtable\endlongtable 360 | \renewenvironment{longtable}{ 361 | \rowcolors{3}{}{table-row-color!100} % row color 362 | \oldlongtable} { 363 | \endoldlongtable 364 | \global\rownum=0\relax} 365 | 366 | % 增加横线 367 | %\ifx\tabularnewline\undefined\else 368 | %\let\oldtabularnewline\tabularnewline 369 | %\renewcommand{\tabularnewline}{\oldtabularnewline\hline} 370 | %\fi 371 | 372 | % ------------------------------------ 373 | % 1.11 列表项缩进 374 | % ------------------------------------ 375 | \usepackage{enumitem} 376 | \let\oldenumerate\enumerate 377 | \let\endoldenumerate\endenumerate 378 | \renewenvironment{enumerate}{ 379 | \oldenumerate[leftmargin=3.75em]} { 380 | \endoldenumerate} 381 | 382 | \let\olditemize\itemize 383 | \let\endolditemize\enditemize 384 | \renewenvironment{itemize}{ 385 | \olditemize[leftmargin=3.25em]} { 386 | \endolditemize} 387 | 388 | 389 | 390 | 391 | 392 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 393 | % 394 | % 二、文档正文 395 | % 2.1 封面 396 | % 2.2 修订记录 397 | % 398 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 399 | \begin{document} 400 | 401 | 402 | % %%%%%%%%%%%%%%%%%%%%%%% 403 | % 2.1 封面 404 | % %%%%%%%%%%%%%%%%%%%%%%% 405 | \begin{titlepage} 406 | 407 | \centering % 文件内容居中 408 | \vspace{1.5\baselineskip} % 标题前的空行 409 | 410 | %------------------------------------------------ 411 | % 文档编号 412 | %------------------------------------------------ 413 | \begin{flushleft} 414 | \textsf{文档编号:$file-code$} 415 | \end{flushleft} 416 | 417 | %------------------------------------------------ 418 | % 标题 419 | %------------------------------------------------ 420 | 421 | \rule{\textwidth}{1.6pt}\vspace*{-\baselineskip}\vspace*{1.5pt} % 粗横线 422 | 423 | \rule{\textwidth}{0.4pt} % 细横线 424 | 425 | \vspace{1.5\baselineskip} % 标题上方的空白 426 | 427 | {\LARGE \textbf{$title$}} % 标题 428 | 429 | \vspace{0.5\baselineskip} 430 | 431 | {\Large \textbf{$version$}} % 版本号 432 | 433 | \vspace{0.75\baselineskip} % Whitespace below the title 434 | 435 | \rule{\textwidth}{0.4pt}\vspace*{-\baselineskip}\vspace{3pt} % 细线 436 | 437 | \rule{\textwidth}{1.6pt} % 粗线 438 | 439 | \vspace{2\baselineskip} % 标题后的空行 440 | 441 | %------------------------------------------------ 442 | % 副标题 443 | %------------------------------------------------ 444 | 445 | {\large \textbf{$subtitle$}} 446 | 447 | 448 | \vspace*{4\baselineskip} % 空行 449 | 450 | %------------------------------------------------ 451 | % 作者信息 452 | %------------------------------------------------ 453 | 454 | 455 | \vspace{0.5\baselineskip} % Whitespace before the editors 456 | 457 | {\scshape\Large \textsf{$for(author)$$author$$sep$ \\ $endfor$}} % 作者 458 | 459 | \vspace{0.5\baselineskip} % 空行 460 | 461 | \vfill % 下方填充 462 | 463 | 464 | %------------------------------------------------ 465 | % 公司信息 466 | %------------------------------------------------ 467 | 468 | $if(logo)$ 469 | \oldincludegraphics[width=50pt,center]{\thelogo} 470 | $endif$ 471 | 472 | \vspace{0.5\baselineskip} % Whitespace under the publisher logo 473 | 474 | {\large \textbf{$if(company)$$company$$else$\company$endif$}} % 公司 475 | 476 | \vspace{0.5\baselineskip} 477 | 478 | \textsf{$date$} % 日期 479 | 480 | \end{titlepage} 481 | \restoregeometry 482 | 483 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 484 | % 2.2 修订记录 485 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 486 | \setcounter{page}{1} 487 | \pagenumbering{Roman} 488 | 489 | $if(history)$ 490 | \setlength{\parindent}{0.5em} 491 | 492 | {\Large \textbf{修订记录}} 493 | 494 | % 表格开始 495 | \begin{longtable}[]{@{}cccl@{}} 496 | 497 | % 表头 498 | \toprule 499 | \begin{minipage}[b]{0.09\columnwidth}\centering 500 | \textbf{序号}\strut 501 | \end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering 502 | \textbf{修订人}\strut 503 | \end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\centering 504 | \textbf{修订时间}\strut 505 | \end{minipage} & \begin{minipage}[b]{0.54\columnwidth}\centering 506 | \textbf{修订记录}\strut 507 | \end{minipage}\tabularnewline 508 | \midrule 509 | \endfirsthead 510 | \toprule 511 | \begin{minipage}[b]{0.09\columnwidth}\centering 512 | \textbf{序号}\strut 513 | \end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering 514 | \textbf{修订人}\strut 515 | \end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\centering 516 | \textbf{修订时间}\strut 517 | \end{minipage} & \begin{minipage}[b]{0.54\columnwidth}\centering 518 | \textbf{修订记录}\strut 519 | \end{minipage}\tabularnewline 520 | \midrule 521 | \endhead 522 | % 表头结束 523 | 524 | % 表格正文 525 | $for(history)$ 526 | 527 | \begin{minipage}[t]{0.09\columnwidth}\centering 528 | $history.version$\strut 529 | \end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering 530 | $history.author$\strut 531 | \end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering 532 | $history.date$\strut 533 | \end{minipage} & \begin{minipage}[t]{0.54\columnwidth}\raggedright 534 | 535 | $for(history.desc)$ 536 | 537 | $history.desc$ 538 | $endfor$\strut 539 | % end of items 540 | \end{minipage}\tabularnewline 541 | $endfor$ 542 | % 表格正文结束 543 | 544 | \bottomrule 545 | \end{longtable} 546 | 547 | \newpage 548 | \setlength{\parindent}{\udfparindent} 549 | $endif$ 550 | 551 | 552 | % %%%%%%%%%%%%%%%%%%%%%%% 553 | % 2.3 目录(包括正文目录和图表目录) 554 | % %%%%%%%%%%%%%%%%%%%%%%% 555 | 556 | % 正文目录 557 | \renewcommand*\contentsname{目录} 558 | { 559 | 560 | % 一级目录也增加引导线 561 | \titlecontents{section}[0pt]{\addvspace{4mm}\filright} 562 | {\bfseries\contentspush{\bfseries{\thecontentslabel}\hspace{1.2mm}\ }} 563 | {}{\titlerule*[8pt]{\textbf{.}}\hspace*{0.3em}\textbf{\contentspage}} 564 | 565 | \setcounter{tocdepth}{3} 566 | \tableofcontents 567 | \newpage 568 | } 569 | 570 | % 图目录 571 | $if(lof)$ 572 | \listoffigures 573 | \newpage 574 | $endif$ 575 | 576 | 577 | % 表目录 578 | $if(lot)$ 579 | \listoftables 580 | \newpage 581 | $endif$ 582 | 583 | 584 | 585 | % %%%%%%%%%%%%%%%%%%%%%%% 586 | % 2.3 正文 587 | % %%%%%%%%%%%%%%%%%%%%%%% 588 | 589 | % 页码重新开始是计算 590 | \setcounter{page}{1} 591 | \pagenumbering{arabic} 592 | 593 | % 表格重新开始编号,为什么是0,不是1,我也不清楚 594 | \setcounter{table}{0} 595 | 596 | $body$ 597 | 598 | \end{document} 599 | 600 | 601 | -------------------------------------------------------------------------------- /templates/eppdev-doc.latex: -------------------------------------------------------------------------------- 1 | % %%%%%%%%%%%%%%%%% 2 | % 3 | % This is the eppdev letax template, used to generate pdf 4 | % file from markdown 5 | % 6 | % Copyrigh jinlong.hao 2019, ALL right preserved! 7 | % 8 | % Licensed by Anti-996 License V1.0 9 | % 10 | % %% 11 | 12 | 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | % 15 | % 〇、模板基础配置 16 | % 17 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18 | 19 | % 公司和组织 20 | \newcommand*{\company}{$if(company)$$company$$else$EPPDEV.CN$endif$} 21 | 22 | % 缩进 23 | \newcommand*{\udfparindent}{2em} 24 | 25 | % 主要中文字体 26 | \newcommand*{\thecjkmainfont}{$if(CJKmainfont)$$CJKmainfont$$else$Microsoft YaHei$endif$} 27 | 28 | % 主要英文字体 29 | \newcommand*{\themainfont}{$if(mainfont)$$mainfont$$else$Microsoft YaHei$endif$} 30 | 31 | % logo 32 | \newcommand*{\thelogo}{$if(logo-url)$$logo-url$$else$logo.png$endif$} 33 | 34 | % 页眉-左 35 | \newcommand*{\headerleft}{$if(header-left)$$header-left$$else$$title$$endif$} 36 | 37 | % 页眉-右 38 | \newcommand*{\headerright}{$if(header-right)$$header-right$$else$企业机密,请勿外传$endif$} 39 | 40 | % 页脚-左 41 | \newcommand*{\footerleft}{$if(footer-left)$$footer-left$$else$\company$endif$} 42 | 43 | % 页脚-右 44 | \newcommand*{\footerright}{\thepage} 45 | 46 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47 | % 48 | % 一、文档基础配置 49 | % 1.1 文档类型 50 | % 1.2 段落、字体及缩进设置 51 | % 1.3 颜色设置 52 | % 1.4 目录设置 53 | % 1.5 页眉页脚 54 | % 1.6 代码块listing设置 55 | % 1.7 图片设置 56 | % 1.8 引用quote设置 57 | % 1.9 注释captions设置 58 | % 1.10 表格table样式设置 59 | % 60 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 61 | 62 | % ----------------------------------- 63 | % 1.1 文档类型 64 | % ----------------------------------- 65 | \PassOptionsToPackage{unicode}{hyperref} 66 | \PassOptionsToPackage{hyphens}{url} 67 | \PassOptionsToPackage{dvipsnames,svgnames*,x11names*,table}{xcolor} 68 | \documentclass[ 69 | $if(fontsize)$ 70 | $fontsize$, 71 | $endif$ 72 | a4paper 73 | ]{scrartcl} 74 | 75 | \usepackage{longtable,booktabs} 76 | \usepackage{framed} 77 | \usepackage{listings} 78 | \usepackage{graphicx,grffile} 79 | \usepackage{titletoc} 80 | \usepackage{soul} 81 | 82 | % ---------------------------------- 83 | % 1.2 段落、字体及缩进设置 84 | % ---------------------------------- 85 | \usepackage{lmodern} 86 | \usepackage{setspace} 87 | 88 | % 1.2倍行距 89 | \setstretch{1.2} 90 | \usepackage{amssymb,amsmath} 91 | 92 | % 字体设置 93 | \usepackage{ifxetex,ifluatex} 94 | \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex 95 | \usepackage[T1]{fontenc} 96 | \usepackage[utf8]{inputenc} 97 | \usepackage{textcomp} % provide euro and other symbols 98 | \else % if luatex or xetex 99 | \usepackage{unicode-math} 100 | \defaultfontfeatures{Scale=MatchLowercase} 101 | \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} 102 | \setmainfont{\themainfont} 103 | \ifxetex 104 | \usepackage{xeCJK} 105 | \setCJKmainfont{\thecjkmainfont} 106 | \setCJKsansfont{\thecjkmainfont} 107 | \fi 108 | \ifluatex 109 | \usepackage[]{luatexja-fontspec} 110 | \setmainjfont{\thecjkmainfont} 111 | \setCJKsansfont{\thecjkmainfont} 112 | \fi 113 | \fi 114 | 115 | % 缩进 116 | \usepackage{indentfirst} 117 | \setlength{\parindent}{\udfparindent} 118 | 119 | % 页边距 120 | \usepackage[margin=2.5cm,includehead=true,includefoot=true,centering]{geometry} 121 | 122 | % ------------------------------------------- 123 | % 1.3 颜色配置 124 | % ------------------------------------------- 125 | 126 | % 颜色 127 | \usepackage{color} 128 | \usepackage{xcolor} 129 | \definecolor{default-linkcolor}{HTML}{100000} 130 | \definecolor{default-filecolor}{HTML}{100000} 131 | \definecolor{default-citecolor}{HTML}{101010} 132 | \definecolor{default-urlcolor}{HTML}{4077C0} 133 | \usepackage{hyperref} 134 | \hypersetup{ 135 | pdftitle={$title$}, 136 | pdfauthor={$author$}, 137 | colorlinks=true, 138 | linkcolor=$if(linkcolor)$$linkcolor$$else$default-linkcolor$endif$, 139 | filecolor=$if(filecolor)$$filecolor$$else$default-filecolor$endif$, 140 | citecolor=$if(citecolor)$$citecolor$$else$default-citecolor$endif$, 141 | urlcolor=$if(urlcolor)$$urlcolor$$else$default-urlcolor$endif$, 142 | breaklinks=true, 143 | pdfcreator={latex via pandoc with eppdev-pandoc-template}} 144 | \urlstyle{same} % disable monospaced font for URLs 145 | $if(strikeout)$ 146 | \usepackage[normalem]{ulem} 147 | % Avoid problems with \sout in headers with hyperref 148 | \pdfstringdefDisableCommands{\renewcommand{\sout}{}} 149 | $endif$ 150 | \providecommand{\tightlist}{% 151 | \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} 152 | 153 | 154 | 155 | % ------------------------------------------ 156 | % 1.4 目录设置 157 | % ------------------------------------------ 158 | 159 | % 目录层级 160 | \setcounter{secnumdepth}{5} 161 | 162 | % paragraph和subparagraph当作目录来处理 163 | \ifx\paragraph\undefined\else 164 | \let\oldparagraph\paragraph 165 | \renewcommand{\paragraph}[1]{ 166 | \setlength{\parindent}{0em} 167 | \oldparagraph{#1}\mbox{} 168 | \setlength{\parindent}{\udfparindent} 169 | } 170 | \fi 171 | \ifx\subparagraph\undefined\else 172 | \let\oldsubparagraph\subparagraph 173 | \renewcommand{\subparagraph}[1]{ 174 | \setlength{\parindent}{0em} 175 | \noindent\oldsubparagraph{#1}\mbox{} 176 | \setlength{\parindent}{\udfparindent} 177 | } 178 | \fi 179 | 180 | % ------------------------------------------- 181 | % 1.5 页眉页脚 182 | % ------------------------------------------- 183 | \usepackage{fancyhdr} 184 | 185 | \fancypagestyle{eppdev-header-footer}{ 186 | \fancyhead{} 187 | \fancyfoot{} 188 | \lhead[\headerright]{\headerleft} 189 | \chead[]{} 190 | \rhead[\headerleft]{\headerright} 191 | \lfoot[\footerright]{\footerleft} 192 | \cfoot[]{} 193 | \rfoot[\footerleft]{\footerright} 194 | \renewcommand{\headrulewidth}{0.4pt} 195 | \renewcommand{\footrulewidth}{0.4pt} 196 | } 197 | \pagestyle{eppdev-header-footer} 198 | 199 | 200 | % ---------------------------------------- 201 | % 1.6 listing设置 202 | % ---------------------------------------- 203 | \usepackage{listings} 204 | \newcommand{\passthrough}[1]{#1} 205 | \lstset{defaultdialect=[5.3]Lua} 206 | \lstset{defaultdialect=[x86masm]Assembler} 207 | 208 | $if(highlighting-macros)$ 209 | $highlighting-macros$ 210 | $endif$ 211 | 212 | 213 | % 基础颜色 214 | \definecolor{listing-background}{HTML}{F7F7F7} 215 | \definecolor{listing-rule}{HTML}{B3B2B3} 216 | \definecolor{listing-numbers}{HTML}{B3B2B3} 217 | \definecolor{listing-text-color}{HTML}{000000} 218 | \definecolor{listing-keyword}{HTML}{435489} 219 | \definecolor{listing-identifier}{HTML}{435489} 220 | \definecolor{listing-string}{HTML}{00999A} 221 | \definecolor{listing-comment}{HTML}{8E8E8E} 222 | \definecolor{listing-javadoc-comment}{HTML}{006CA9} 223 | 224 | % java 颜色 225 | \lstdefinestyle{eppdev-listing-style}{ 226 | language = java, 227 | numbers = left, 228 | xleftmargin = 2.7em, 229 | framexleftmargin = 2.5em, 230 | backgroundcolor = \color{listing-background}, 231 | basicstyle = \color{listing-text-color}\small\ttfamily{}\linespread{1.15}, % print whole listing small 232 | breaklines = true, 233 | frame = single, 234 | framesep = 0.19em, 235 | rulecolor = \color{listing-rule}, 236 | frameround = ffff, 237 | tabsize = 4, 238 | numberstyle = \color{listing-numbers}, 239 | aboveskip = 1.0em, 240 | belowskip = 0.1em, 241 | abovecaptionskip = 0em, 242 | belowcaptionskip = 1.0em, 243 | keywordstyle = \color{listing-keyword}\bfseries, 244 | classoffset = 0, 245 | sensitive = true, 246 | identifierstyle = \color{listing-identifier}, 247 | commentstyle = \color{listing-comment}, 248 | morecomment = [s][\color{listing-javadoc-comment}]{/**}{*/}, 249 | stringstyle = \color{listing-string}, 250 | showstringspaces = false, 251 | escapeinside = {/*@}{@*/}, % Allow LaTeX inside these special comments 252 | literate = 253 | {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1 254 | {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1 255 | {à}{{\`a}}1 {è}{{\'e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1 256 | {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1 257 | {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1 258 | {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1 259 | {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1 260 | {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1 261 | {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1 262 | {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1 263 | {€}{{\EUR}}1 {£}{{\pounds}}1 {«}{{\guillemotleft}}1 264 | {»}{{\guillemotright}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?`}}1 265 | {…}{{\ldots}}1 {≥}{{>=}}1 {≤}{{<=}}1 {„}{{\glqq}}1 {“}{{\grqq}}1 266 | {”}{{''}}1 267 | } 268 | \lstset{style=eppdev-listing-style} 269 | 270 | \lstdefinelanguage{XML}{ 271 | morestring = [b]", 272 | moredelim = [s][\bfseries\color{listing-keyword}]{<}{\ }, 273 | moredelim = [s][\bfseries\color{listing-keyword}]{}, 274 | moredelim = [l][\bfseries\color{listing-keyword}]{/>}, 275 | moredelim = [l][\bfseries\color{listing-keyword}]{>}, 276 | morecomment = [s]{}, 277 | morecomment = [s]{}, 278 | commentstyle = \color{listing-comment}, 279 | stringstyle = \color{listing-string}, 280 | identifierstyle = \color{listing-identifier} 281 | } 282 | 283 | 284 | 285 | 286 | % -------------------------------------------- 287 | % 1.7 图片设置 288 | % -------------------------------------------- 289 | 290 | % 设置图片的大小 291 | $if(graphics)$ 292 | \usepackage{graphicx,grffile} 293 | \makeatletter 294 | \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} 295 | \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi} 296 | \makeatother 297 | \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} 298 | $endif$ 299 | 300 | 301 | \usepackage{graphicx,grffile} 302 | \usepackage[export]{adjustbox} 303 | 304 | 305 | % 设置图片不要缩进 306 | \ifx\includegraphics\undefined\else 307 | \let\oldincludegraphics\includegraphics 308 | \renewcommand{\includegraphics}[1]{ 309 | \vskip 8pt 310 | \setlength{\parindent}{0em} 311 | \oldincludegraphics{#1} 312 | \setlength{\parindent}{\udfparindent} 313 | \vskip 2pt 314 | } 315 | \fi 316 | 317 | % figure不浮动 318 | \usepackage{float} 319 | \floatplacement{figure}{H} 320 | 321 | 322 | % ------------------------------------------- 323 | % 1.8 引用的格式 324 | % ------------------------------------------- 325 | \definecolor{blockquote-border}{RGB}{221,221,221} 326 | \definecolor{blockquote-text}{RGB}{119,119,119} 327 | \usepackage{mdframed} 328 | \newmdenv[rightline=false,bottomline=false,topline=false,linewidth=3pt,linecolor=blockquote-border,skipabove=\parskip]{customblockquote} 329 | \renewenvironment{quote}{\vskip 8pt \small \begin{customblockquote}\list{}{\rightmargin=0em\leftmargin=0em}% 330 | \item\relax\color{blockquote-text}\ignorespaces}{\unskip\unskip\endlist\end{customblockquote}} 331 | 332 | % -------------------------------------------- 333 | % 1.9 Captions的格式 334 | % -------------------------------------------- 335 | \definecolor{caption-color}{HTML}{777777} 336 | \usepackage[font={scriptsize}]{caption} 337 | \setcapindent{0em} 338 | \captionsetup[figure]{labelfont={bf},labelformat={default},labelsep=period,name={图}} 339 | \captionsetup[table]{labelfont={bf},labelformat={default},labelsep=period,name={表}} 340 | 341 | 342 | 343 | % -------------------------------------------- 344 | % 1.10 表格样式设置 345 | % -------------------------------------------- 346 | \usepackage{longtable} 347 | \definecolor{table-row-color}{HTML}{EFEFEF} 348 | \definecolor{table-rule-color}{HTML}{999999} 349 | 350 | %\arrayrulecolor{black!40} 351 | \arrayrulecolor{table-rule-color} % color of \toprule, \midrule, \bottomrule 352 | \setlength\heavyrulewidth{0.3ex} % thickness of \toprule, \bottomrule 353 | \renewcommand{\arraystretch}{1.3} % spacing (padding) 354 | 355 | % Reset rownum counter so that each table 356 | % starts with the same row colors. 357 | % https://tex.stackexchange.com/questions/170637/restarting-rowcolors 358 | \let\oldlongtable\longtable 359 | \let\endoldlongtable\endlongtable 360 | \renewenvironment{longtable}{ 361 | \rowcolors{3}{}{table-row-color!100} % row color 362 | \oldlongtable} { 363 | \endoldlongtable 364 | \global\rownum=0\relax} 365 | 366 | % 增加横线 367 | %\ifx\tabularnewline\undefined\else 368 | %\let\oldtabularnewline\tabularnewline 369 | %\renewcommand{\tabularnewline}{\oldtabularnewline\hline} 370 | %\fi 371 | 372 | % ------------------------------------ 373 | % 1.11 列表项缩进 374 | % ------------------------------------ 375 | \usepackage{enumitem} 376 | \let\oldenumerate\enumerate 377 | \let\endoldenumerate\endenumerate 378 | \renewenvironment{enumerate}{ 379 | \oldenumerate[leftmargin=3.75em]} { 380 | \endoldenumerate} 381 | 382 | \let\olditemize\itemize 383 | \let\endolditemize\enditemize 384 | \renewenvironment{itemize}{ 385 | \olditemize[leftmargin=3.25em]} { 386 | \endolditemize} 387 | 388 | 389 | 390 | 391 | 392 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 393 | % 394 | % 二、文档正文 395 | % 2.1 封面 396 | % 2.2 修订记录 397 | % 398 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 399 | \begin{document} 400 | 401 | 402 | % %%%%%%%%%%%%%%%%%%%%%%% 403 | % 2.1 封面 404 | % %%%%%%%%%%%%%%%%%%%%%%% 405 | \begin{titlepage} 406 | 407 | \centering % 文件内容居中 408 | \vspace{1.5\baselineskip} % 标题前的空行 409 | 410 | %------------------------------------------------ 411 | % 文档编号 412 | %------------------------------------------------ 413 | \begin{flushleft} 414 | \textsf{文档编号:$file-code$} 415 | \end{flushleft} 416 | 417 | %------------------------------------------------ 418 | % 标题 419 | %------------------------------------------------ 420 | 421 | \rule{\textwidth}{1.6pt}\vspace*{-\baselineskip}\vspace*{1.5pt} % 粗横线 422 | 423 | \rule{\textwidth}{0.4pt} % 细横线 424 | 425 | \vspace{1.5\baselineskip} % 标题上方的空白 426 | 427 | {\LARGE \textbf{$title$}} % 标题 428 | 429 | \vspace{0.5\baselineskip} 430 | 431 | {\Large \textbf{$version$}} % 版本号 432 | 433 | \vspace{0.75\baselineskip} % Whitespace below the title 434 | 435 | \rule{\textwidth}{0.4pt}\vspace*{-\baselineskip}\vspace{3pt} % 细线 436 | 437 | \rule{\textwidth}{1.6pt} % 粗线 438 | 439 | \vspace{2\baselineskip} % 标题后的空行 440 | 441 | %------------------------------------------------ 442 | % 副标题 443 | %------------------------------------------------ 444 | 445 | {\large \textbf{$subtitle$}} 446 | 447 | 448 | \vspace*{4\baselineskip} % 空行 449 | 450 | %------------------------------------------------ 451 | % 作者信息 452 | %------------------------------------------------ 453 | 454 | 455 | \vspace{0.5\baselineskip} % Whitespace before the editors 456 | 457 | {\scshape\Large \textsf{$for(author)$$author$$sep$ \\ $endfor$}} % 作者 458 | 459 | \vspace{0.5\baselineskip} % 空行 460 | 461 | \vfill % 下方填充 462 | 463 | 464 | %------------------------------------------------ 465 | % 公司信息 466 | %------------------------------------------------ 467 | 468 | $if(logo)$ 469 | \oldincludegraphics[width=50pt,center]{\thelogo} 470 | $endif$ 471 | 472 | \vspace{0.5\baselineskip} % Whitespace under the publisher logo 473 | 474 | {\large \textbf{$if(company)$$company$$else$\company$endif$}} % 公司 475 | 476 | \vspace{0.5\baselineskip} 477 | 478 | \textsf{$date$} % 日期 479 | 480 | \end{titlepage} 481 | \restoregeometry 482 | 483 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 484 | % 2.2 修订记录 485 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 486 | \setcounter{page}{1} 487 | \pagenumbering{Roman} 488 | 489 | $if(history)$ 490 | \setlength{\parindent}{0.5em} 491 | 492 | {\Large \textbf{修订记录}} 493 | 494 | % 表格开始 495 | \begin{longtable}[]{@{}cccl@{}} 496 | 497 | % 表头 498 | \toprule 499 | \begin{minipage}[b]{0.09\columnwidth}\centering 500 | \textbf{序号}\strut 501 | \end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering 502 | \textbf{修订人}\strut 503 | \end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\centering 504 | \textbf{修订时间}\strut 505 | \end{minipage} & \begin{minipage}[b]{0.54\columnwidth}\centering 506 | \textbf{修订记录}\strut 507 | \end{minipage}\tabularnewline 508 | \midrule 509 | \endfirsthead 510 | \toprule 511 | \begin{minipage}[b]{0.09\columnwidth}\centering 512 | \textbf{序号}\strut 513 | \end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering 514 | \textbf{修订人}\strut 515 | \end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\centering 516 | \textbf{修订时间}\strut 517 | \end{minipage} & \begin{minipage}[b]{0.54\columnwidth}\centering 518 | \textbf{修订记录}\strut 519 | \end{minipage}\tabularnewline 520 | \midrule 521 | \endhead 522 | % 表头结束 523 | 524 | % 表格正文 525 | $for(history)$ 526 | 527 | \begin{minipage}[t]{0.09\columnwidth}\centering 528 | $history.version$\strut 529 | \end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering 530 | $history.author$\strut 531 | \end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering 532 | $history.date$\strut 533 | \end{minipage} & \begin{minipage}[t]{0.54\columnwidth}\raggedright 534 | 535 | $for(history.desc)$ 536 | 537 | $history.desc$ 538 | $endfor$\strut 539 | % end of items 540 | \end{minipage}\tabularnewline 541 | $endfor$ 542 | % 表格正文结束 543 | 544 | \bottomrule 545 | \end{longtable} 546 | 547 | \newpage 548 | \setlength{\parindent}{\udfparindent} 549 | $endif$ 550 | 551 | 552 | % %%%%%%%%%%%%%%%%%%%%%%% 553 | % 2.3 目录(包括正文目录和图表目录) 554 | % %%%%%%%%%%%%%%%%%%%%%%% 555 | 556 | % 正文目录 557 | \renewcommand*\contentsname{目录} 558 | { 559 | 560 | % 一级目录也增加引导线 561 | \titlecontents{section}[0pt]{\addvspace{4mm}\filright} 562 | {\bfseries\contentspush{\bfseries{\thecontentslabel}\hspace{1.2mm}\ }} 563 | {}{\titlerule*[8pt]{\textbf{.}}\hspace*{0.3em}\textbf{\contentspage}} 564 | 565 | \setcounter{tocdepth}{3} 566 | \tableofcontents 567 | \newpage 568 | } 569 | 570 | % 图目录 571 | $if(lof)$ 572 | \listoffigures 573 | \newpage 574 | $endif$ 575 | 576 | 577 | % 表目录 578 | $if(lot)$ 579 | \listoftables 580 | \newpage 581 | $endif$ 582 | 583 | 584 | 585 | % %%%%%%%%%%%%%%%%%%%%%%% 586 | % 2.3 正文 587 | % %%%%%%%%%%%%%%%%%%%%%%% 588 | 589 | % 页码重新开始是计算 590 | \setcounter{page}{1} 591 | \pagenumbering{arabic} 592 | 593 | % 表格重新开始编号,为什么是0,不是1,我也不清楚 594 | \setcounter{table}{0} 595 | 596 | $body$ 597 | 598 | \end{document} 599 | 600 | 601 | -------------------------------------------------------------------------------- /templates/eppdev-doc-mac.latex: -------------------------------------------------------------------------------- 1 | % %%%%%%%%%%%%%%%%% 2 | % 3 | % This is the eppdev letax template, used to generate pdf 4 | % file from markdown 5 | % 6 | % Copyrigh jinlong.hao 2019, ALL right preserved! 7 | % 8 | % Licensed by Anti-996 License V1.0 9 | % 10 | % %% 11 | 12 | 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | % 15 | % 〇、模板基础配置 16 | % 17 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18 | 19 | % 公司和组织 20 | \newcommand*{\company}{$if(company)$$company$$else$EPPDEV.CN$endif$} 21 | 22 | % 缩进 23 | \newcommand*{\udfparindent}{2em} 24 | 25 | % 主要中文字体 26 | \newcommand*{\thecjkmainfont}{$if(CJKmainfont)$$CJKmainfont$$else$PingFang SC$endif$} 27 | 28 | % 主要英文字体 29 | \newcommand*{\themainfont}{$if(mainfont)$$mainfont$$else$PingFang SC$endif$} 30 | 31 | % logo 32 | \newcommand*{\thelogo}{$if(logo-url)$$logo-url$$else$logo.png$endif$} 33 | 34 | % 页眉-左 35 | \newcommand*{\headerleft}{$if(header-left)$$header-left$$else$$title$$endif$} 36 | 37 | % 页眉-右 38 | \newcommand*{\headerright}{$if(header-right)$$header-right$$else$企业机密,请勿外传$endif$} 39 | 40 | % 页脚-左 41 | \newcommand*{\footerleft}{$if(footer-left)$$footer-left$$else$\company$endif$} 42 | 43 | % 页脚-右 44 | \newcommand*{\footerright}{\thepage} 45 | 46 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47 | % 48 | % 一、文档基础配置 49 | % 1.1 文档类型 50 | % 1.2 段落、字体及缩进设置 51 | % 1.3 颜色设置 52 | % 1.4 目录设置 53 | % 1.5 页眉页脚 54 | % 1.6 代码块listing设置 55 | % 1.7 图片设置 56 | % 1.8 引用quote设置 57 | % 1.9 注释captions设置 58 | % 1.10 表格table样式设置 59 | % 60 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 61 | 62 | % ----------------------------------- 63 | % 1.1 文档类型 64 | % ----------------------------------- 65 | \PassOptionsToPackage{unicode}{hyperref} 66 | \PassOptionsToPackage{hyphens}{url} 67 | \PassOptionsToPackage{dvipsnames,svgnames*,x11names*,table}{xcolor} 68 | \documentclass[ 69 | $if(fontsize)$ 70 | $fontsize$, 71 | $endif$ 72 | a4paper 73 | ]{scrartcl} 74 | 75 | \usepackage{longtable,booktabs} 76 | \usepackage{framed} 77 | \usepackage{listings} 78 | \usepackage{graphicx,grffile} 79 | \usepackage{titletoc} 80 | \usepackage{soul} 81 | 82 | 83 | % ---------------------------------- 84 | % 1.2 段落、字体及缩进设置 85 | % ---------------------------------- 86 | \usepackage{lmodern} 87 | \usepackage{setspace} 88 | 89 | % 1.2倍行距 90 | \setstretch{1.2} 91 | \usepackage{amssymb,amsmath} 92 | 93 | % 字体设置 94 | \usepackage{ifxetex,ifluatex} 95 | \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex 96 | \usepackage[T1]{fontenc} 97 | \usepackage[utf8]{inputenc} 98 | \usepackage{textcomp} % provide euro and other symbols 99 | \else % if luatex or xetex 100 | \usepackage{unicode-math} 101 | \defaultfontfeatures{Scale=MatchLowercase} 102 | \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} 103 | \setmainfont{\themainfont} 104 | \ifxetex 105 | \usepackage{xeCJK} 106 | \setCJKmainfont{\thecjkmainfont} 107 | \setCJKsansfont{\thecjkmainfont} 108 | \fi 109 | \ifluatex 110 | \usepackage[]{luatexja-fontspec} 111 | \setmainjfont{\thecjkmainfont} 112 | \setCJKsansfont{\thecjkmainfont} 113 | \fi 114 | \fi 115 | 116 | % 缩进 117 | \usepackage{indentfirst} 118 | \setlength{\parindent}{\udfparindent} 119 | 120 | % 页边距 121 | \usepackage[margin=2.5cm,includehead=true,includefoot=true,centering]{geometry} 122 | 123 | % ------------------------------------------- 124 | % 1.3 颜色配置 125 | % ------------------------------------------- 126 | 127 | % 颜色 128 | \usepackage{color} 129 | \usepackage{xcolor} 130 | \definecolor{default-linkcolor}{HTML}{100000} 131 | \definecolor{default-filecolor}{HTML}{100000} 132 | \definecolor{default-citecolor}{HTML}{101010} 133 | \definecolor{default-urlcolor}{HTML}{4077C0} 134 | \usepackage{hyperref} 135 | \hypersetup{ 136 | pdftitle={$title$}, 137 | pdfauthor={$author$}, 138 | colorlinks=true, 139 | linkcolor=$if(linkcolor)$$linkcolor$$else$default-linkcolor$endif$, 140 | filecolor=$if(filecolor)$$filecolor$$else$default-filecolor$endif$, 141 | citecolor=$if(citecolor)$$citecolor$$else$default-citecolor$endif$, 142 | urlcolor=$if(urlcolor)$$urlcolor$$else$default-urlcolor$endif$, 143 | breaklinks=true, 144 | pdfcreator={latex via pandoc with eppdev-pandoc-template}} 145 | \urlstyle{same} % disable monospaced font for URLs 146 | $if(strikeout)$ 147 | \usepackage[normalem]{ulem} 148 | % Avoid problems with \sout in headers with hyperref 149 | \pdfstringdefDisableCommands{\renewcommand{\sout}{}} 150 | $endif$ 151 | \providecommand{\tightlist}{% 152 | \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} 153 | 154 | 155 | 156 | % ------------------------------------------ 157 | % 1.4 目录设置 158 | % ------------------------------------------ 159 | 160 | % 目录层级 161 | \setcounter{secnumdepth}{5} 162 | 163 | % paragraph和subparagraph当作目录来处理 164 | \ifx\paragraph\undefined\else 165 | \let\oldparagraph\paragraph 166 | \renewcommand{\paragraph}[1]{ 167 | \setlength{\parindent}{0em} 168 | \oldparagraph{#1}\mbox{} 169 | \setlength{\parindent}{\udfparindent} 170 | } 171 | \fi 172 | \ifx\subparagraph\undefined\else 173 | \let\oldsubparagraph\subparagraph 174 | \renewcommand{\subparagraph}[1]{ 175 | \setlength{\parindent}{0em} 176 | \noindent\oldsubparagraph{#1}\mbox{} 177 | \setlength{\parindent}{\udfparindent} 178 | } 179 | \fi 180 | 181 | % ------------------------------------------- 182 | % 1.5 页眉页脚 183 | % ------------------------------------------- 184 | \usepackage{fancyhdr} 185 | 186 | \fancypagestyle{eppdev-header-footer}{ 187 | \fancyhead{} 188 | \fancyfoot{} 189 | \lhead[\headerright]{\headerleft} 190 | \chead[]{} 191 | \rhead[\headerleft]{\headerright} 192 | \lfoot[\footerright]{\footerleft} 193 | \cfoot[]{} 194 | \rfoot[\footerleft]{\footerright} 195 | \renewcommand{\headrulewidth}{0.4pt} 196 | \renewcommand{\footrulewidth}{0.4pt} 197 | } 198 | \pagestyle{eppdev-header-footer} 199 | 200 | 201 | % ---------------------------------------- 202 | % 1.6 listing设置 203 | % ---------------------------------------- 204 | \usepackage{listings} 205 | \newcommand{\passthrough}[1]{#1} 206 | \lstset{defaultdialect=[5.3]Lua} 207 | \lstset{defaultdialect=[x86masm]Assembler} 208 | 209 | $if(highlighting-macros)$ 210 | $highlighting-macros$ 211 | $endif$ 212 | 213 | 214 | % 基础颜色 215 | \definecolor{listing-background}{HTML}{F7F7F7} 216 | \definecolor{listing-rule}{HTML}{B3B2B3} 217 | \definecolor{listing-numbers}{HTML}{B3B2B3} 218 | \definecolor{listing-text-color}{HTML}{000000} 219 | \definecolor{listing-keyword}{HTML}{435489} 220 | \definecolor{listing-identifier}{HTML}{435489} 221 | \definecolor{listing-string}{HTML}{00999A} 222 | \definecolor{listing-comment}{HTML}{8E8E8E} 223 | \definecolor{listing-javadoc-comment}{HTML}{006CA9} 224 | 225 | % java 颜色 226 | \lstdefinestyle{eppdev-listing-style}{ 227 | language = java, 228 | numbers = left, 229 | xleftmargin = 2.7em, 230 | framexleftmargin = 2.5em, 231 | backgroundcolor = \color{listing-background}, 232 | basicstyle = \color{listing-text-color}\small\ttfamily{}\linespread{1.15}, % print whole listing small 233 | breaklines = true, 234 | frame = single, 235 | framesep = 0.19em, 236 | rulecolor = \color{listing-rule}, 237 | frameround = ffff, 238 | tabsize = 4, 239 | numberstyle = \color{listing-numbers}, 240 | aboveskip = 1.0em, 241 | belowskip = 0.1em, 242 | abovecaptionskip = 0em, 243 | belowcaptionskip = 1.0em, 244 | keywordstyle = \color{listing-keyword}\bfseries, 245 | classoffset = 0, 246 | sensitive = true, 247 | identifierstyle = \color{listing-identifier}, 248 | commentstyle = \color{listing-comment}, 249 | morecomment = [s][\color{listing-javadoc-comment}]{/**}{*/}, 250 | stringstyle = \color{listing-string}, 251 | showstringspaces = false, 252 | escapeinside = {/*@}{@*/}, % Allow LaTeX inside these special comments 253 | literate = 254 | {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1 255 | {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1 256 | {à}{{\`a}}1 {è}{{\'e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1 257 | {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1 258 | {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1 259 | {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1 260 | {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1 261 | {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1 262 | {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1 263 | {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1 264 | {€}{{\EUR}}1 {£}{{\pounds}}1 {«}{{\guillemotleft}}1 265 | {»}{{\guillemotright}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?`}}1 266 | {…}{{\ldots}}1 {≥}{{>=}}1 {≤}{{<=}}1 {„}{{\glqq}}1 {“}{{\grqq}}1 267 | {”}{{''}}1 268 | } 269 | \lstset{style=eppdev-listing-style} 270 | 271 | \lstdefinelanguage{XML}{ 272 | morestring = [b]", 273 | moredelim = [s][\bfseries\color{listing-keyword}]{<}{\ }, 274 | moredelim = [s][\bfseries\color{listing-keyword}]{}, 275 | moredelim = [l][\bfseries\color{listing-keyword}]{/>}, 276 | moredelim = [l][\bfseries\color{listing-keyword}]{>}, 277 | morecomment = [s]{}, 278 | morecomment = [s]{}, 279 | commentstyle = \color{listing-comment}, 280 | stringstyle = \color{listing-string}, 281 | identifierstyle = \color{listing-identifier} 282 | } 283 | 284 | 285 | 286 | 287 | % -------------------------------------------- 288 | % 1.7 图片设置 289 | % -------------------------------------------- 290 | 291 | % 设置图片的大小 292 | $if(graphics)$ 293 | \usepackage{graphicx,grffile} 294 | \makeatletter 295 | \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} 296 | \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi} 297 | \makeatother 298 | \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} 299 | $endif$ 300 | 301 | 302 | \usepackage{graphicx,grffile} 303 | \usepackage[export]{adjustbox} 304 | 305 | 306 | % 设置图片不要缩进 307 | \ifx\includegraphics\undefined\else 308 | \let\oldincludegraphics\includegraphics 309 | \renewcommand{\includegraphics}[1]{ 310 | \vskip 8pt 311 | \setlength{\parindent}{0em} 312 | \oldincludegraphics{#1} 313 | \setlength{\parindent}{\udfparindent} 314 | \vskip 2pt 315 | } 316 | \fi 317 | 318 | % figure不浮动 319 | \usepackage{float} 320 | \floatplacement{figure}{H} 321 | 322 | 323 | % ------------------------------------------- 324 | % 1.8 引用的格式 325 | % ------------------------------------------- 326 | \definecolor{blockquote-border}{RGB}{221,221,221} 327 | \definecolor{blockquote-text}{RGB}{119,119,119} 328 | \usepackage{mdframed} 329 | \newmdenv[rightline=false,bottomline=false,topline=false,linewidth=3pt,linecolor=blockquote-border,skipabove=\parskip]{customblockquote} 330 | \renewenvironment{quote}{\vskip 8pt \small \begin{customblockquote}\list{}{\rightmargin=0em\leftmargin=0em}% 331 | \item\relax\color{blockquote-text}\ignorespaces}{\unskip\unskip\endlist\end{customblockquote}} 332 | 333 | % -------------------------------------------- 334 | % 1.9 Captions的格式 335 | % -------------------------------------------- 336 | \definecolor{caption-color}{HTML}{777777} 337 | \usepackage[font={scriptsize}]{caption} 338 | \setcapindent{0em} 339 | \captionsetup[figure]{labelfont={bf},labelformat={default},labelsep=period,name={图}} 340 | \captionsetup[table]{labelfont={bf},labelformat={default},labelsep=period,name={表}} 341 | 342 | 343 | 344 | % -------------------------------------------- 345 | % 1.10 表格样式设置 346 | % -------------------------------------------- 347 | \usepackage{longtable} 348 | \definecolor{table-row-color}{HTML}{EFEFEF} 349 | \definecolor{table-rule-color}{HTML}{999999} 350 | 351 | %\arrayrulecolor{black!40} 352 | \arrayrulecolor{table-rule-color} % color of \toprule, \midrule, \bottomrule 353 | \setlength\heavyrulewidth{0.3ex} % thickness of \toprule, \bottomrule 354 | \renewcommand{\arraystretch}{1.3} % spacing (padding) 355 | 356 | % Reset rownum counter so that each table 357 | % starts with the same row colors. 358 | % https://tex.stackexchange.com/questions/170637/restarting-rowcolors 359 | \let\oldlongtable\longtable 360 | \let\endoldlongtable\endlongtable 361 | \renewenvironment{longtable}{ 362 | \rowcolors{3}{}{table-row-color!100} % row color 363 | \oldlongtable} { 364 | \endoldlongtable 365 | \global\rownum=0\relax} 366 | 367 | % 增加横线 368 | %\ifx\tabularnewline\undefined\else 369 | %\let\oldtabularnewline\tabularnewline 370 | %\renewcommand{\tabularnewline}{\oldtabularnewline\hline} 371 | %\fi 372 | 373 | % ------------------------------------ 374 | % 1.11 列表项缩进 375 | % ------------------------------------ 376 | \usepackage{enumitem} 377 | \let\oldenumerate\enumerate 378 | \let\endoldenumerate\endenumerate 379 | \renewenvironment{enumerate}{ 380 | \oldenumerate[leftmargin=3.75em]} { 381 | \endoldenumerate} 382 | 383 | \let\olditemize\itemize 384 | \let\endolditemize\enditemize 385 | \renewenvironment{itemize}{ 386 | \olditemize[leftmargin=3.25em]} { 387 | \endolditemize} 388 | 389 | 390 | 391 | 392 | 393 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 394 | % 395 | % 二、文档正文 396 | % 2.1 封面 397 | % 2.2 修订记录 398 | % 399 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 400 | \begin{document} 401 | 402 | 403 | % %%%%%%%%%%%%%%%%%%%%%%% 404 | % 2.1 封面 405 | % %%%%%%%%%%%%%%%%%%%%%%% 406 | \begin{titlepage} 407 | 408 | \centering % 文件内容居中 409 | \vspace{1.5\baselineskip} % 标题前的空行 410 | 411 | %------------------------------------------------ 412 | % 文档编号 413 | %------------------------------------------------ 414 | \begin{flushleft} 415 | \textsf{文档编号:$file-code$} 416 | \end{flushleft} 417 | 418 | %------------------------------------------------ 419 | % 标题 420 | %------------------------------------------------ 421 | 422 | \rule{\textwidth}{1.6pt}\vspace*{-\baselineskip}\vspace*{1.5pt} % 粗横线 423 | 424 | \rule{\textwidth}{0.4pt} % 细横线 425 | 426 | \vspace{1.5\baselineskip} % 标题上方的空白 427 | 428 | {\LARGE \textbf{$title$}} % 标题 429 | 430 | \vspace{0.5\baselineskip} 431 | 432 | {\Large \textbf{$version$}} % 版本号 433 | 434 | \vspace{0.75\baselineskip} % Whitespace below the title 435 | 436 | \rule{\textwidth}{0.4pt}\vspace*{-\baselineskip}\vspace{3pt} % 细线 437 | 438 | \rule{\textwidth}{1.6pt} % 粗线 439 | 440 | \vspace{2\baselineskip} % 标题后的空行 441 | 442 | %------------------------------------------------ 443 | % 副标题 444 | %------------------------------------------------ 445 | 446 | {\large \textbf{$subtitle$}} 447 | 448 | 449 | \vspace*{4\baselineskip} % 空行 450 | 451 | %------------------------------------------------ 452 | % 作者信息 453 | %------------------------------------------------ 454 | 455 | 456 | \vspace{0.5\baselineskip} % Whitespace before the editors 457 | 458 | {\scshape\Large \textsf{$for(author)$$author$$sep$ \\ $endfor$}} % 作者 459 | 460 | \vspace{0.5\baselineskip} % 空行 461 | 462 | \vfill % 下方填充 463 | 464 | 465 | %------------------------------------------------ 466 | % 公司信息 467 | %------------------------------------------------ 468 | 469 | $if(logo)$ 470 | %--\oldincludegraphics[width=50pt,center]{\thelogo} 471 | $endif$ 472 | 473 | \vspace{0.5\baselineskip} % Whitespace under the publisher logo 474 | 475 | {\large \textbf{$if(company)$$company$$else$\company$endif$}} % 公司 476 | 477 | \vspace{0.5\baselineskip} 478 | 479 | \textsf{$date$} % 日期 480 | 481 | \end{titlepage} 482 | \restoregeometry 483 | 484 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 485 | % 2.2 修订记录 486 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 487 | \setcounter{page}{1} 488 | \pagenumbering{Roman} 489 | 490 | $if(history)$ 491 | \setlength{\parindent}{0.5em} 492 | 493 | {\Large \textbf{修订记录}} 494 | 495 | % 表格开始 496 | \begin{longtable}[]{@{}cccl@{}} 497 | 498 | % 表头 499 | \toprule 500 | \begin{minipage}[b]{0.09\columnwidth}\centering 501 | \textbf{序号}\strut 502 | \end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering 503 | \textbf{修订人}\strut 504 | \end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\centering 505 | \textbf{修订时间}\strut 506 | \end{minipage} & \begin{minipage}[b]{0.54\columnwidth}\centering 507 | \textbf{修订记录}\strut 508 | \end{minipage}\tabularnewline 509 | \midrule 510 | \endfirsthead 511 | \toprule 512 | \begin{minipage}[b]{0.09\columnwidth}\centering 513 | \textbf{序号}\strut 514 | \end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\centering 515 | \textbf{修订人}\strut 516 | \end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\centering 517 | \textbf{修订时间}\strut 518 | \end{minipage} & \begin{minipage}[b]{0.54\columnwidth}\centering 519 | \textbf{修订记录}\strut 520 | \end{minipage}\tabularnewline 521 | \midrule 522 | \endhead 523 | % 表头结束 524 | 525 | % 表格正文 526 | $for(history)$ 527 | 528 | \begin{minipage}[t]{0.09\columnwidth}\centering 529 | $history.version$\strut 530 | \end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\centering 531 | $history.author$\strut 532 | \end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\centering 533 | $history.date$\strut 534 | \end{minipage} & \begin{minipage}[t]{0.54\columnwidth}\raggedright 535 | 536 | $for(history.desc)$ 537 | 538 | $history.desc$ 539 | $endfor$\strut 540 | % end of items 541 | \end{minipage}\tabularnewline 542 | $endfor$ 543 | % 表格正文结束 544 | 545 | \bottomrule 546 | \end{longtable} 547 | 548 | \newpage 549 | \setlength{\parindent}{\udfparindent} 550 | $endif$ 551 | 552 | 553 | % %%%%%%%%%%%%%%%%%%%%%%% 554 | % 2.3 目录(包括正文目录和图表目录) 555 | % %%%%%%%%%%%%%%%%%%%%%%% 556 | 557 | % 正文目录 558 | \renewcommand*\contentsname{目录} 559 | { 560 | 561 | % 一级目录也增加引导线 562 | \titlecontents{section}[0pt]{\addvspace{4mm}\filright} 563 | {\bfseries\contentspush{\bfseries{\thecontentslabel}\hspace{1.2mm}\ }} 564 | {}{\titlerule*[8pt]{\textbf{.}}\hspace*{0.3em}\textbf{\contentspage}} 565 | 566 | \setcounter{tocdepth}{3} 567 | \tableofcontents 568 | \newpage 569 | } 570 | 571 | % 图目录 572 | $if(lof)$ 573 | \listoffigures 574 | \newpage 575 | $endif$ 576 | 577 | 578 | % 表目录 579 | $if(lot)$ 580 | \listoftables 581 | \newpage 582 | $endif$ 583 | 584 | 585 | 586 | % %%%%%%%%%%%%%%%%%%%%%%% 587 | % 2.3 正文 588 | % %%%%%%%%%%%%%%%%%%%%%%% 589 | 590 | % 页码重新开始是计算 591 | \setcounter{page}{1} 592 | \pagenumbering{arabic} 593 | 594 | % 表格重新开始编号,为什么是0,不是1,我也不清楚 595 | \setcounter{table}{0} 596 | 597 | $body$ 598 | 599 | \end{document} 600 | 601 | 602 | --------------------------------------------------------------------------------