Files
worldmodel/plans/PRISM/tools/book_template.tex
T

276 lines
12 KiB
TeX
Raw 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.
% =====================================================================
% PRISM Book — Pandoc/XeLaTeX 模板
% 适配:macOS + TinyTeX + ctex + xeCJK,可独立 xelatex 编译
% =====================================================================
\documentclass[11pt,a4paper,oneside,openany]{ctexbook}
% ── 几何 / 字体 / 中文 ────────────────────────────────────────────────
\usepackage[a4paper,margin=2.4cm,headheight=24pt,headsep=0.5cm,footskip=1.2cm]{geometry}
\usepackage{amssymb} % 提供 \boxtimes, \checkmark 等任务列表符号
\usepackage{amsmath}
\usepackage{xeCJK}
\setCJKmainfont[BoldFont={STHeiti},ItalicFont={STKaiti}]{STSong}
\setCJKsansfont{STHeiti}
\setCJKmonofont{STHeiti}
\setmainfont{Helvetica Neue}
\setsansfont{Helvetica Neue}
\setmonofont{Menlo}[Scale=0.85]
\linespread{1.20}
% 让 xelatex 允许在 CJK 字符之间断行(关键!);
% 否则一行长中文(常见于表格单元、长描述)即使在 p{w} 列里也不会自动换行,
% 导致 Overfull \hbox 大量溢出。
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt
% URL 也允许任意位置断开,避免长链接溢出
\usepackage{xurl}
% sloppy 模式:允许 inter-word 间距稍微变化以避免溢出
\sloppy
\emergencystretch=3em
% 改用 hyphenat:允许在所有字符之间断行,主要为长下划线文件名/URL/路径。
% 比 seqsplit 安全 — 它能在 \section / \texttt 中正常工作。
\usepackage[htt]{hyphenat}
% 对 etoolbox 提供的 \pretocmd 用 \texttt 包裹时启用低惩罚断字
% (\texttt 内部已是 \ttfamily,hyphenat 的 htt 选项让 ttfamily 也能断字)
% ── 颜色 / 框 / 代码 ──────────────────────────────────────────────────
\usepackage{xcolor}
\definecolor{PrismRed}{HTML}{E63946}
\definecolor{PrismOrange}{HTML}{F77F00}
\definecolor{PrismYellow}{HTML}{FCBF49}
\definecolor{PrismTeal}{HTML}{2A9D8F}
\definecolor{PrismBlue}{HTML}{1D7AB8}
\definecolor{PrismPurple}{HTML}{5A189A}
\definecolor{InkDark}{HTML}{0E1116}
\definecolor{InkMuted}{HTML}{4A5560}
\definecolor{BoxBG}{HTML}{F4F2EB}
\definecolor{CodeBG}{HTML}{F6F7F9}
\definecolor{CodeBorder}{HTML}{D7DBE0}
\definecolor{Accent}{HTML}{1D7AB8}
\definecolor{GoldRule}{HTML}{C9A227}
\usepackage[most]{tcolorbox}
\tcbset{
enhanced, breakable, boxrule=0pt, arc=2pt,
colback=BoxBG, colframe=Accent, fonttitle=\bfseries,
before skip=4pt, after skip=4pt,
left=8pt, right=8pt, top=4pt, bottom=4pt,
beforeafter skip balanced
}
\usepackage{listings}
\lstdefinestyle{prism}{
basicstyle=\ttfamily\footnotesize,
backgroundcolor=\color{CodeBG},
frame=single, rulecolor=\color{CodeBorder},
framesep=4pt, framerule=0.4pt,
xleftmargin=8pt, xrightmargin=8pt,
showstringspaces=false,
breaklines=true, breakatwhitespace=false,
keywordstyle=\color{PrismPurple}\bfseries,
commentstyle=\color{InkMuted}\itshape,
stringstyle=\color{PrismTeal},
numberstyle=\tiny\color{InkMuted}, numbers=none,
upquote=true, columns=flexible,
literate=
{á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
{}{{$\rightarrow$}}1 {}{{$\leftarrow$}}1
{}{{$\geq$}}1 {}{{$\leq$}}1 {±}{{$\pm$}}1 {}{{$\approx$}}1
{×}{{$\times$}}1 {}{{$\cdots$}}1 {·}{{·}}1
{}{{\ldots}}1 {}{{$\Box$}}1
}
\lstset{style=prism}
% pandoc 用 fancyvrb 转 verbatim;用 fvextra 扩展自动换行能力,避免长注释/长字符串超出页宽
\usepackage{fvextra}
\DefineVerbatimEnvironment{Verbatim}{Verbatim}{%
fontsize=\footnotesize,%
breaklines=true,%
breakanywhere=true,%
breaksymbolleft={},%
breaksymbolright={},%
}
% 用 tcolorbox 来包代码块,既能套色又能正确处理换页
\definecolor{CodeBoxBG}{HTML}{F6F7F9}
\definecolor{CodeBoxRule}{HTML}{D7DBE0}
\makeatletter
\@ifundefined{Shaded}{%
\newtcolorbox{ShadedBox}{
enhanced, breakable,
colback=CodeBoxBG, colframe=CodeBoxRule,
boxrule=0.4pt, arc=2pt,
left=6pt, right=6pt, top=4pt, bottom=4pt,
before skip=4pt, after skip=4pt
}
\newenvironment{Shaded}{\begin{ShadedBox}}{\end{ShadedBox}}%
}{}
\makeatother
% pandoc syntax-highlight 需要的环境与命令
\usepackage{upquote}
% pandoc 用法:\begin{Shaded}\begin{Highlighting}[options]...\end{Highlighting}\end{Shaded}
% 所以 Highlighting 内部 只做 Verbatim,背景已由外层 Shaded(=ShadedBox tcolorbox)负责
\makeatletter
\@ifundefined{Highlighting}{%
\newenvironment{Highlighting}[1][]{%
\VerbatimEnvironment%
\begin{Verbatim}[fontsize=\footnotesize,commandchars=\\\{\},#1]%
}{%
\end{Verbatim}%
}%
}{}
\makeatother
% ── 表格 / 列表 ────────────────────────────────────────────────────────
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{tabularx}
\usepackage{makecell}
\usepackage{enumitem}
\setlist{nosep,leftmargin=*}
% ── 图 / 链接 ──────────────────────────────────────────────────────────
\usepackage{graphicx}
\usepackage{float}
\usepackage[unicode=true,colorlinks=true,
linkcolor=Accent, citecolor=Accent, urlcolor=Accent,
pdftitle={PRISM v__PRISM_VERSION__ — Prior-Registered Integrated Spatial Memory},
pdfauthor={Project Planning Team},
pdfsubject={PRISM v__PRISM_VERSION__, built __PRISM_BUILD_DATE__},
pdfkeywords={PRISM, RoomPlan, ZED 2i, SLAM, Spatial Memory, Robot, World Model}]{hyperref}
% ── 页眉页脚 ──────────────────────────────────────────────────────────
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\small\textsf{\textcolor{InkMuted}{PRISM \textbullet{} 机器人大脑空间记忆架构 \textbullet{} v__PRISM_VERSION__}}}
\fancyhead[R]{\small\textsf{\textcolor{InkMuted}{\leftmark}}}
\fancyfoot[L]{\small\textsf{\textcolor{InkMuted}{Build: __PRISM_BUILD_DATE__}}}
\fancyfoot[C]{\small\textsf{\textcolor{InkMuted}{\thepage{} / \pageref*{LastPage}}}}
\fancyfoot[R]{\small\textsf{\textcolor{InkMuted}{v__PRISM_VERSION__}}}
\renewcommand{\headrulewidth}{0.3pt}
\renewcommand{\headrule}{\hbox to\headwidth{\color{GoldRule}\leaders\hrule height \headrulewidth\hfill}}
\renewcommand{\footrulewidth}{0pt}
\usepackage{lastpage}
% ── 章节样式 ──────────────────────────────────────────────────────────
\ctexset{
chapter={
name={第,章},
number=\arabic{chapter},
format=\Large\bfseries\sffamily\raggedright,
titleformat=\Large\bfseries\sffamily\raggedright,
aftername={\hspace{0.6em}},
beforeskip=1.2em, afterskip=1.0em
},
section={
format=\large\bfseries\sffamily\raggedright,
aftername={\hspace{0.5em}}
},
subsection={
format=\normalsize\bfseries\sffamily\raggedright,
},
subsubsection={
format=\normalsize\sffamily\raggedright,
}
}
% ── pandoc 兼容包 ─────────────────────────────────────────────────────
\usepackage{calc} % pandoc 表格列宽需要 calc 包
\providecommand{\tightlist}{\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\providecommand{\pandocbounded}[1]{#1}
\providecommand{\real}[1]{#1} % pandoc:把 0.4545 原样传入 calc
\providecommand{\textquotesingle}{\textsf{'}}
% Pandoc 用 \def\LTcaptype{none};需要先定义 none counter 避免 \refstepcounter{none} 报错
\newcounter{none}
% 一些 pandoc highlight 占位 (避免缺命令报错)
\providecommand{\NormalTok}[1]{#1}
\providecommand{\KeywordTok}[1]{\textcolor{PrismPurple}{\textbf{#1}}}
\providecommand{\DataTypeTok}[1]{\textcolor{PrismTeal}{#1}}
\providecommand{\DecValTok}[1]{\textcolor{PrismOrange}{#1}}
\providecommand{\BaseNTok}[1]{\textcolor{PrismOrange}{#1}}
\providecommand{\FloatTok}[1]{\textcolor{PrismOrange}{#1}}
\providecommand{\CharTok}[1]{\textcolor{PrismTeal}{#1}}
\providecommand{\StringTok}[1]{\textcolor{PrismTeal}{#1}}
\providecommand{\CommentTok}[1]{\textcolor{InkMuted}{\textit{#1}}}
\providecommand{\OtherTok}[1]{#1}
\providecommand{\AlertTok}[1]{\textcolor{PrismRed}{\textbf{#1}}}
\providecommand{\FunctionTok}[1]{\textcolor{Accent}{#1}}
\providecommand{\RegionMarkerTok}[1]{#1}
\providecommand{\ErrorTok}[1]{\textcolor{PrismRed}{\textbf{#1}}}
\providecommand{\BuiltInTok}[1]{#1}
\providecommand{\ExtensionTok}[1]{#1}
\providecommand{\PreprocessorTok}[1]{\textcolor{PrismOrange}{#1}}
\providecommand{\AttributeTok}[1]{#1}
\providecommand{\InformationTok}[1]{\textcolor{InkMuted}{#1}}
\providecommand{\WarningTok}[1]{\textcolor{PrismOrange}{\textbf{#1}}}
\providecommand{\AnnotationTok}[1]{\textcolor{InkMuted}{\textit{#1}}}
\providecommand{\VariableTok}[1]{#1}
\providecommand{\ImportTok}[1]{\textcolor{PrismPurple}{#1}}
\providecommand{\OperatorTok}[1]{#1}
\providecommand{\ControlFlowTok}[1]{\textcolor{PrismPurple}{\textbf{#1}}}
\providecommand{\SpecialCharTok}[1]{#1}
\providecommand{\VerbatimStringTok}[1]{\textcolor{PrismTeal}{#1}}
\providecommand{\SpecialStringTok}[1]{\textcolor{PrismTeal}{#1}}
\providecommand{\ConstantTok}[1]{\textcolor{PrismOrange}{#1}}
\providecommand{\DocumentationTok}[1]{\textcolor{InkMuted}{\textit{#1}}}
\providecommand{\CommentVarTok}[1]{\textcolor{InkMuted}{\textit{#1}}}
% pandoc 引文环境
\newenvironment{cslreferences}{}{}
\newcommand{\citeproctext}{}
\newcommand{\citeproc}[2]{#2}
% emoji / unicode 兜底 (xeCJK 大多直接显示;不显示的用 textsf 代替)
\newcommand{\emoji}[1]{\texorpdfstring{#1}{}}
% ─────────────────────────────────────────────────────────────────────
\title{\bfseries PRISM \\[6pt]
\large Prior-Registered Integrated Spatial Memory \\[3pt]
\normalsize 机器人大脑空间记忆架构 \\[6pt]
\small\sffamily\textcolor{InkMuted}{v__PRISM_VERSION__ \textperiodcentered{} __PRISM_BUILD_DATE__}}
\author{项目规划组 \textperiodcentered{} Project Planning Team}
\date{__PRISM_BUILD_DATE__ \textperiodcentered{} v__PRISM_VERSION__}
\begin{document}
\frontmatter
\maketitle
% 简短前言 (一页)
\thispagestyle{empty}
\vspace*{2em}
\begin{tcolorbox}[title={关于本书 / About this Book},
colback=BoxBG, colframe=Accent]
\textbf{PRISM} (Prior-Registered Integrated Spatial Memory) 是一种把
\emph{iPhone RoomPlan 离线先验地图}\emph{ZED 2i 双目+IMU 在线感知}
融合进同一个机器人大脑的\textbf{四层空间记忆架构}
本书完整收录 PRISM v1.1 方案的 15 个章节
(README + 14 章),含可立即复制运行的 Python schema、ROS 2 节点编排、
8 周路线图、风险登记、评测体系、以及一份周末可跑通的最小 MVP。
\end{tcolorbox}
\vfill
\noindent\textsf{\textcolor{InkMuted}{\small
\textbf{License}: CC BY-NC 4.0 \hfill
\textbf{Repo}: \texttt{github.com/<org>/prism}\\
\textbf{文档版本}: v1.1 \hfill
\textbf{最后更新}: 2026-05-16
}}
\cleardoublepage
\tableofcontents
\cleardoublepage
\mainmatter
% ─────────── 正文由 pandoc 注入 ───────────
__PRISM_BODY_PLACEHOLDER__
\end{document}