Skip to content

Commit

Permalink
Refine contents
Browse files Browse the repository at this point in the history
  • Loading branch information
xjtu-blacksmith committed Jan 8, 2020
1 parent 5535253 commit 25116b2
Show file tree
Hide file tree
Showing 5 changed files with 278 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Custom files
*.pdf
!qyxf-book.pdf

## Core latex/pdflatex auxiliary files:
*.aux
*.lof
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# qyxf-book
钱院学辅 LaTeX 书籍模板
# qyxf-book:钱院学辅 LaTeX 书籍模板

`qyxf-book` 是由钱院学辅开发的,专门用于排版中等以上体量资料的 LaTeX 文类。目前,该模板已被用于编写了《大学物理题解》、《理论力学题解》、《计算方法撷英》等诸多资料。

本份模板原在 [qyxf-sets 宏集](https://github.com/qyxf/qyxf-sets)项目中开发;因维护成本不高、效果不理想,现独立维护,并不再使用之前的 doc/doctrip 方式。现采用 MIT 协议许可,请大家放心地 fork、修改。

本仓库中附带一份 `demo.tex`,请各位用户参考该文件,或直接在其基础上改写出自己的资料。
Binary file added cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions demo.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
\documentclass[
b5paper, % 默认为 a4paper
sourcefont, % 电脑上未装齐对应字体时,请勿打开该选项
%opensource, % 输出开源信息
decoration, % 打开装饰
]{qyxf-book}

\title{高等数学入门}
\subtitle{Advanced Mathematics Primer}
\author{白山雁}
\typo{红山雁} % 排版人员信息
\date{2019 年 2 月 29 日}

% 开启 opensource 选项时,以下信息必须填写
% \sourcepage{https://example.com/}

\begin{document}

\maketitle

\tableofcontents

\chapter{极限理论}
\section{极限的定义}

极限是一种过程……

\[ \lim_{n\to\infty}\frac1n = 0 \]

\section{极限的计算方法}
\subsection{观察法}

\chapter{一元微分学}

\end{document}
232 changes: 232 additions & 0 deletions qyxf-book.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
% --------------------------
% qyxf-book 钱院学辅书籍模板
% 如不清楚含义,请勿随意更改
% --------------------------

\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\ProvidesClass{qyxf-book}
[2020/01/08 v2.2 Qian Yuan Xue Fu book template]
\typeout{The book template provided by Qian Yuan Xue Fu}
\LoadClass[10pt, twoside, openany]{book}

% 选项定制与处理
\newif\if@decoration
\newif\if@opensource
\newif\if@sourcefont
\DeclareOption{a4paper}{
\setlength\paperheight{297mm}%
\setlength\paperwidth{210mm}}
\DeclareOption{b5paper}{
\setlength\paperheight{250mm}%
\setlength\paperwidth{176mm}}
\DeclareOption{color}{}
\DeclareOption{parskip}{
\setlength\parskip{0.2\baselineskip}}
\DeclareOption{decoration}{\@decorationtrue}
\DeclareOption{plain}{\@decorationfalse}
\DeclareOption{opensource}{\@opensourcetrue}
\DeclareOption{sourcefont}{\@sourcefonttrue}
\ProcessOptions

% 字体处理
\if@sourcefont % 启用自定义字体
\PassOptionsToPackage{SlantFont}{xeCJK}
\RequirePackage[heading,fontset=none]{ctex}
\setCJKmainfont{思源宋体}
\setCJKsansfont{思源黑体}
\newCJKfontfamily[zhfs]\fangsong{FangSong} % 调用仿宋
\renewcommand\CJKttdefault{zhfs}
\setmainfont{Cambria} % 目前默认使用的 serif 字体
\setsansfont{Calibri} % 目前默认使用的 sans-serif 字体
\setmonofont{Courier New} % 目前默认使用的等宽字体
\RequirePackage{amsmath} % 防止冲突
\RequirePackage{unicode-math} % 数学字体
\setmathfont{Cambria Math} % 与正文字体相适应的数学字体
\else % 使用默认字体
\RequirePackage[heading]{ctex}
\RequirePackage{amsmath}
\fi

% 脚注样式调整
\renewcommand{\thefootnote}{\textbf{(\arabic{footnote})}}

% 浮动体(图表)处理
\RequirePackage{graphicx}
\graphicspath{{./figure/}{./pic/}{./image}}
\setlength{\textfloatsep}{6pt plus 2pt minus 4pt}
\setlength{\intextsep}{6pt plus 2pt minus 2pt}
\RequirePackage{longtable,booktabs}
\RequirePackage{tikz}
\usetikzlibrary{calc,backgrounds,shadows}
\RequirePackage{tcolorbox,tabu}
\tcbuselibrary{listings,theorems,skins}

% 自定义命令 / 环境
\newcommand{\exercise}[1]{\noindent\tcbox[on line,top=0mm,bottom=0mm,right=0mm,left=0mm]{\bfseries 练习#1}\ }
\newcommand{\note}{\noindent\textbf{注记}\ }
\newcommand{\solve}{\noindent\textbf{}\ }
\newcommand{\analysis}{\noindent\textbf{分析}\ }

% 页面设置
\RequirePackage{geometry}
\geometry{margin=1in}
\setlength{\footskip}{30pt}

% 链接设置
\RequirePackage{hyperref}
\hypersetup{
breaklinks,
unicode,
linktoc=all,
bookmarksnumbered=true,
bookmarksopen=true,
pdfborder={0 0 0},
linktocpage,
pageanchor=true}

% 装饰样式设置
\RequirePackage{pgfornament-han}
\RequirePackage{pgfornament}
\newcommand{\decoration}{
\vspace{-1ex}\centering
\begin{tikzpicture}
\node at (0,0) {\pgfornamenthan[scale=0.2,symmetry=h]{60}};
\node[fill opacity=0.2,draw opacity=0] at (0.02,-0.03)
{\pgfornamenthan[scale=0.2,symmetry=h]{60}};
\end{tikzpicture}}

% 章节标题与目录样式
\RequirePackage{titlesec,titletoc}
\ctexset{section={name={\S,}}}
\titleformat{\chapter}[block]{
\centering\bfseries\fontsize{2.5em}{1ex}
}{\CTEXthechapter}
{1em}{}[\if@decoration\decoration\fi]
\titlespacing{\chapter}{0pt}{*1}{*4}
\titlecontents{chapter}[24pt]{\hspace{-2pc}\filright}
{\normalsize\bfseries\contentspush{\thecontentslabel\ }}
{}{\bfseries\titlerule*[8pt]{.}\contentspage}
\titlecontents{section}[20pt]{\filright}
{\contentspush{\thecontentslabel\ }}
{}{\titlerule*[8pt]{.}\contentspage}
\titlecontents{subsection}[18pt]{\hspace{2pc}\filright}
{\contentspush{\thecontentslabel\ }\itshape}
{}{\titlerule*[8pt]{}\contentspage}
\setcounter{tocdepth}{2}

% 页眉页脚设置
\RequirePackage{fancyhdr}
\newcommand{\footdeco}{
\resizebox{10em}{5ex}{
\begin{tikzpicture}
\node at (0,0) {\pgfornamenthan[scale=0.05]{58}};
\node[opacity=0.2, draw opacity=0] at (0.02,-0.03) {\pgfornamenthan[scale=0.05]{58}};
\end{tikzpicture}}\\[-1ex]}
\fancyhead[EC]{\fangsong\nouppercase\leftmark}
\fancyhead[OC]{\fangsong\nouppercase\rightmark}
\fancyhead[EL,OR]{\bf\thepage}
\fancyhead[ER,OL]{}
\fancyfoot[C]{\if@decoration\footdeco\else\vspace{1ex}\fi\textsc{Qian Yuan Xue Fu}}
\fancypagestyle{plain}{%
\fancyhf{}
\fancyfoot[C]{\if@decoration\footdeco\else\vspace{1ex}\fi\textsc{Qian Yuan Xue Fu}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\setlength{\headheight}{13pt}

% 杂项
\RequirePackage{lastpage}
\RequirePackage{enumerate}
\RequirePackage{pifont}
\RequirePackage{appendix}
\ctexset{appendix={number={\Roman{chapter}}}}
\RequirePackage[scale=1.1]{ccicons}

% 若干 metadata
\newtoks\subtitle
\newtoks\typo
\newtoks\version
\newtoks\sourcepage

% 标题样式重定义
\renewcommand*{\maketitle}{%
\hypersetup{
pageanchor=false,
pdfauthor=\@author,
pdftitle=\@title,
pdfsubject={\@author: \@title - \the\subtitle},
pdfkeywords={qyxf, book},
pdfcreator={XeLaTeX with qyxf-book class}
}
\begin{titlepage}
\phantom{s}
\vspace{3cm}
\begin{center}\large
\begin{tcolorbox}[blanker,borderline west={1mm}{0pt}{black!90},%
left=20pt,bottom=0.5ex,after skip=0pt]
{\fontsize{40pt}{\baselineskip}\selectfont\bfseries\@title}\\[0.5\baselineskip]
{\Huge\itshape\the\subtitle}
\end{tcolorbox}
\begin{tcolorbox}[blanker,borderline west={1mm}{0pt}{black!40},%
left=20pt,top=0.5ex,before skip=0pt]
{\Large 作者:\@author\\[0.2\baselineskip]
\@date}
\end{tcolorbox}
\vfill
\texttt{钱学森书院学业辅导中心}\\[0.5\baselineskip]
\textsc{Qian Yuan Xue Fu}\\[0.5\baselineskip]
{XI'AN JIAOTONG UNIVERSITY}
\end{center}
\begin{tikzpicture}[remember picture,overlay]
\begin{pgfonlayer}{background}
\node at ($(current page.east) +(0in,0in)$) {%
\includegraphics[width=0.8\textwidth]{cover.png}};
\end{pgfonlayer}
\end{tikzpicture}
\end{titlepage}
\thispagestyle{empty}
\newpage
\hypersetup{pageanchor=true}
\phantom{s}\vfill
\begin{tcolorbox}[title={\bfseries 作品信息}]
\ding{228} \textbf{标题:}\@title{} - \textit{\the\subtitle}\\
\ding{228} \textbf{作者:}\@author\\
\ding{228} \textbf{校对排版:}\the\typo\\
\ding{228} \textbf{出品时间:}\@date\\
\ding{228} \textbf{总页数:}\pageref{LastPage}
\end{tcolorbox}
\begin{tcolorbox}[title={\bfseries 许可证说明}]
\centerline{\tcbox{\ccbyncnd\ \fangsong 知识共享 (Creative Commons) BY-NC-ND 4.0 协议}%
\\[0.3\baselineskip]}
本作品采用 \href{https://creativecommons.org/licenses/by-nc-nd/4.0/}{\textbf{CC协议}}
进行许可。使用者可以在给出作者署名及资料来源的前提下对本作品进行转载,
但不得对本作品进行修改,亦不得基于本作品进行二次创作,
不得将本作品运用于商业用途。
\end{tcolorbox}
\if@opensource
\begin{tcolorbox}
本作品已发布于GitHub之上,发布地址为:\\
\centerline{\the\sourcepage}
本作品的版本号为\textsf{\the\version}。
\end{tcolorbox}
\fi
\newpage
\pagestyle{fancy}
}

% 目录样式重定义
\renewcommand\tableofcontents{%
\pagestyle{empty}
\centerline{%
\normalfont\LARGE\bfseries\contentsname%
\@mkboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}
}
\vskip 3ex%
{\setlength\parskip{0pt}\@starttoc{toc}}
\cleardoublepage
\pagestyle{fancy}
\setcounter{page}{1}
}

\endinput

0 comments on commit 25116b2

Please sign in to comment.