Skip to content

Commit

Permalink
feat:add mono font
Browse files Browse the repository at this point in the history
1. Add the configuration of code fonts;
2. Add font recommendation;
3. Add a reference to a source
  • Loading branch information
Dunky-Z committed Aug 21, 2022
1 parent 41965f2 commit b383701
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 34 deletions.
37 changes: 31 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ LaTex工具,在windows下建议安装miktex,Linux和MacOS下建议安装texl
- 正文缩进,目前默认是`0em`
- 主要中文字体和英文字体:目前都是微软雅黑
- 页眉、页脚展示内容,目前是:
- 左页眉:title
- 左页眉:标题
- 右页眉:"企业机密-禁止外传"
- 左页脚:company
- 右页脚:页码
Expand All @@ -81,11 +81,31 @@ LaTex工具,在windows下建议安装miktex,Linux和MacOS下建议安装texl

目前页面默认的字体是微软雅黑,对于非Windows系统,可能不存在该字体,则有以下两种解决方案:

1. 手工安装微软雅黑字体(需要msyh,msyhbd两个文件)
2. 修改为其他字体,如苹方、文泉驿等
1. 微软雅黑属于商业字体,无法分享,可以自行下载安装,字体名为`Microsoft YaHei`
1. 修改为已安装的其他字体
- 将文档最前面的字体配置改为
```
CJKmainfont: 中文字体名称
mainfont: 英文字体名称
monofont: 代码字体字体名称
```
### 字体推荐
若需要多个团队共同使用,建议采用方案一。
- 中文字体:思源宋体
- 英文字体:微软雅黑
- 代码字体:JetBrainsMono
> 因为大部分用户还是装有微软雅黑,为了方便开箱即用所以没有将默认字体设为这两款字体。
1. 下载安装这两款字体[思源宋体](https://source.typekit.com/source-han-serif/cn/),[JetBrains Mono](https://www.jetbrains.com/lp/mono/)。
1. 将文档最前面的字体配置改为
```
CJKmainfont: SourceHanSerifSC-Medium
monofont: JetBrainsMono-Medium
```
对比
![](./img/compare.png)
# 生成PDF
Expand Down Expand Up @@ -118,7 +138,8 @@ history:
- footer-left: 左页脚
- footer-right: 右页脚
- CJKmainfont: 主要中文字体
- mainfont: 主要字体
- mainfont: 主要英文字体
- monofont: 主要代码字体
- lot: 是否创建表格目录
- lof: 是否创建图片目录

Expand All @@ -128,4 +149,8 @@ history:

```bash
pandoc --listings --pdf-engine=xelatex --template=mppl.latex README.md -o README.pdf
```
```

# 参考

模板主要修改自[eppdev/eppdev-pandoc-template](https://github.com/eppdev/eppdev-pandoc-template)
Binary file added img/compare.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion samples/mppl-sample.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ output:
title: "Markdown语法简明教程"
version: V0.1
author: "Dominic"
date: "2019-08"
date: "2022-08"
company: COMPANYNAME
file-code: COMPANY-DEPARTMENT-00000000
logo: true
logo-url: ../img/Markdown-mark.png
lot: true
lof: true
CJKmainfont: Microsoft YaHei
mainfont: Microsoft YaHei
monofont: Consolas
history:
- version: V0.1
author: Dominic
Expand Down
Binary file modified samples/mppl-sample.pdf
Binary file not shown.
58 changes: 31 additions & 27 deletions templates/mppl.latex
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
% 主要英文字体
\newcommand*{\themainfont}{$if(mainfont)$$mainfont$$else$Microsoft YaHei$endif$}

% Mono字体,用于代码块
\newcommand*{\themonofont}{$if(monofont)$$monofont$$else$Consolas$endif$}

% logo
\newcommand*{\thelogo}{$if(logo-url)$$logo-url$$else$logo.png$endif$}

Expand Down Expand Up @@ -101,6 +104,7 @@ $endif$
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\setmainfont{\themainfont}
\setmonofont{\themonofont}
\ifxetex
\usepackage{xeCJK}
\setCJKmainfont{\thecjkmainfont}
Expand Down Expand Up @@ -130,7 +134,7 @@ $endif$
\definecolor{default-linkcolor}{HTML}{100000}
\definecolor{default-filecolor}{HTML}{100000}
\definecolor{default-citecolor}{HTML}{101010}
\definecolor{default-urlcolor}{HTML}{4077C0}
\definecolor{default-urlcolor}{HTML}{005bbb}
\usepackage{hyperref}
\hypersetup{
pdftitle={$title$},
Expand Down Expand Up @@ -222,33 +226,33 @@ $endif$
\definecolor{listing-comment}{HTML}{8E8E8E}
\definecolor{listing-javadoc-comment}{HTML}{006CA9}

% java 颜色
% 代码块listing设置
\lstdefinestyle{mppl-listing-style}{
language = java,
numbers = left,
xleftmargin = 2.7em,
framexleftmargin = 2.5em,
backgroundcolor = \color{listing-background},
language = java, % 语言类型
numbers = left, % 行号显示位置
xleftmargin = 2.7em, % 左边距
framexleftmargin = 2.5em, % 左边框边距
backgroundcolor = \color{listing-background}, % 背景色
basicstyle = \color{listing-text-color}\small\ttfamily{}\linespread{1.15}, % print whole listing small
breaklines = true,
frame = single,
framesep = 0.19em,
rulecolor = \color{listing-rule},
frameround = ffff,
tabsize = 4,
numberstyle = \color{listing-numbers},
aboveskip = 1.0em,
belowskip = 0.1em,
abovecaptionskip = 0em,
belowcaptionskip = 1.0em,
keywordstyle = \color{listing-keyword}\bfseries,
classoffset = 0,
sensitive = true,
identifierstyle = \color{listing-identifier},
commentstyle = \color{listing-comment},
morecomment = [s][\color{listing-javadoc-comment}]{/**}{*/},
breaklines = true, % 代码超出边界换行
frame = single, % 代码块边框是单线条
framesep = 0.19em, % 边框与代码间距
rulecolor = \color{listing-rule}, % 边框颜色
frameround = tttt, % 边框圆角
tabsize = 4, % tab缩进
numberstyle = \color{listing-numbers}, % 行号颜色
aboveskip = 1.0em, % 上边距
belowskip = 0.1em, % 下边距
abovecaptionskip = 0em, % 上标题边距
belowcaptionskip = 1.0em, % 下标颜边距
keywordstyle = \color{listing-keyword}\bfseries, % 关键字颜色
classoffset = 0, % 类名偏移量
sensitive = true, % 是否区分大小写
identifierstyle = \color{listing-identifier}, % 变量颜色
commentstyle = \color{listing-comment}, % 注释颜色
morecomment = [s][\color{listing-javadoc-comment}]{/**}{*/},
stringstyle = \color{listing-string},
showstringspaces = false,
showstringspaces = false, % 是否显示字符串空格
escapeinside = {/*@}{@*/}, % Allow LaTeX inside these special comments
literate =
{á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
Expand All @@ -264,8 +268,8 @@ $endif$
{€}{{\EUR}}1 {£}{{\pounds}}1 {«}{{\guillemotleft}}1
{»}{{\guillemotright}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?`}}1
{…}{{\ldots}}1 {≥}{{>=}}1 {≤}{{<=}}1 {„}{{\glqq}}1 {“}{{\grqq}}1
{”}{{''}}1
}
{”}{{''}}1
}
\lstset{style=mppl-listing-style}

\lstdefinelanguage{XML}{
Expand Down

0 comments on commit b383701

Please sign in to comment.