Files
laoyang 203e490197 教材:补上封面图
教材/cover.jpg(1281x1024,229K),教材.tex 启用 \cover{cover.jpg}。
封面图铺满页面上方 210x167.9mm,下方接青绿色带,与成书封面结构一致。

README 文件清单补上 cover.jpg。
2026-11-01 12:03:59 +08:00

195 lines
4.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 教材
教材、专著的成书排版,A4 多页,含封面、目录、章节、附录、参考文献。
## 编译
```bash
cd 教材
xelatex 教材.tex
bibtex 教材
xelatex 教材.tex
xelatex 教材.tex
```
或仓库根:`bash build.sh 教材`(自动依次跑完,含 bibtex)
## 文件
| 文件 | 说明 |
|---|---|
| `教材.tex` | 主文件,书名与正文改这里 |
| `ouctextbook.sty` | 版式配置 |
| `elegantbook.cls` | 文档类 |
| `reference.bib` | 参考文献库,换成自己的 |
| `cover.jpg` | 封面图,换成自己的或删掉 |
## ⚠️ 前两行不能动
```latex
\documentclass[lang=cn,newtx,10pt,black,chinesefont=nofont]{elegantbook}
\input{../fonts.tex}
```
- `chinesefont=nofont` 必须写,否则会去加载系统字体或商业字体,跨平台不一致
- `\input{../fonts.tex}` 必须在 `\documentclass` 之后、`\begin{document}` 之前
## 书名信息
```latex
\title{教材模板示例}
\subtitle{副标题写在这里}
\author{作者甲 \quad 作者乙 \quad 作者丙}
\institute{中国海洋大学}
\date{2026/11/1}
\version{第一版}
\extrainfo{出版社}
```
| 命令 | 说明 |
|---|---|
| `\title{}` | 书名 |
| `\subtitle{}` | 副标题 |
| `\author{}` | 作者,多人用 `\quad` 隔开 |
| `\institute{}` | 单位 |
| `\date{}` | 日期 |
| `\version{}` | 版本 |
| `\extrainfo{}` | 出版社 |
### 封面图
不放图就只要纯色带封面。要放图:
```latex
\cover{cover.jpg}
```
图片放进本目录。
### 封面色
默认青绿 RGB(32,178,170)。要换颜色,正文里调:
```latex
\oucSetCoverColor{blue}
```
## 文档结构
```latex
\begin{document}
\maketitle % 标题页
\frontmatter % 前置部分,页码用罗马数字
\tableofcontents % 目录
\chapter*{前言} % 前言(不进编号)
\mainmatter % 正文,页码用阿拉伯数字
\chapter{第一章}
...
\appendix % 附录,章号变 A、B、C
\chapter{附录一}
\nocite{*}
\printbibliography[heading=bibintoc, title=\ebibname]
\end{document}
```
## 章的标准写法
```latex
\chapter{章节标题}
本章导语,3~5 段,概述本章要解决的问题与结构。
\section{节标题}
正文段落。
\subsection{小节标题}
\subsubsection{小小节标题}
\paragraph{第五级标题}
这一级用「(1)(2)(3)」编号。
\oucsummary
本章小结正文。
\oucexercises
\begin{enumerate}
\item 习题一。
\end{enumerate}
```
| 命令 | 说明 |
|---|---|
| `\chapter{}` | 章(1, 2, 3) |
| `\section{}` | 节(1.1) |
| `\subsection{}` | 小节(1.1.1) |
| `\subsubsection{}` | 小小节(1.1.1.1) |
| `\paragraph{}` | 第五级,用(1)(2)(3)编号 |
| `\oucsummary` | 印「本章小结」节标题 |
| `\oucexercises` | 印「习题」节标题 |
编号最多到第 4 级(1.1.1.1),第 5 级不再用点分编号,避免出现
「3.1.1.1.1」这种过长编号。`\paragraph` 的序号随 `\subsubsection` 重置。
## 参考文献
```latex
\addbibresource[location=local]{reference.bib} % 导言区
\nocite{*} % 正文末尾,引用全部条目
\printbibliography[heading=bibintoc, title=\ebibname]
```
`\nocite{*}` 表示列出文献库里全部条目。正式写作时删掉它,只列实际引用的。
`reference.bib` 里的条目是虚构的,替换成自己的文献库。
## 插图与表格
```latex
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{image/xxx.png}
\caption{图标题}
\label{fig:example}
\end{figure}
\begin{table}[htbp]
\centering
\caption{表标题}
\label{tab:example}
\begin{tabular}{|l|l|}
\hline
列一 & 列二 \\ \hline
\end{tabular}
\end{table}
```
图题在图下方,表题在表上方。`[H]` 强制图跟文字,教材排版常用。
TikZ 可直接画关系图、流程图:
```latex
\begin{tikzpicture}[box/.style={draw, rounded corners, align=center,
fill=blue!6, minimum width=3.2cm}]
\node[box] (a) at (0,0) {甲方};
\node[box] (b) at (4,0) {乙方};
\draw[->, thick] (a) -- (b);
\end{tikzpicture}
```
已加载的 TikZ 库:`shapes.geometric`、`shapes.misc`、`arrows.meta`、
`arrows`、`decorations.pathreplacing`、`decorations.markings`、
`positioning`、`calc`、`fit`、`backgrounds`。
## 版式
```
A4,边距 上下 25.4mm,左右 20mm
正文 10pt,行距 1.2 倍
标题:章 22pt 黑体,节 14pt 黑体
封面色带 RGB(32,178,170) 青绿
页码:前置罗马数字,正文阿拉伯数字
```
## 注意
示例内容为占位文字,使用时全部替换。