重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
npx skills add https://github.com/dbosk/claude-skills --skill latex-writing本技能指导创建结构良好、语义正确的 LaTeX 文档,遵循既定的最佳实践。
使用与内容语义含义相匹配的 LaTeX 环境,而不仅仅是视觉外观。
description 处理术语-定义对当您有标签后跟解释、定义或描述时,请使用 description 环境:
\begin{description}
\item[术语] 术语的定义或解释
\item[标签] 与标签相关的内容
\item[属性] 属性的描述
\end{description}
切勿这样做:
\begin{itemize}
\item \textbf{术语:} 定义或解释
\item \textbf{标签:} 与标签相关的内容
\end{itemize}
description 的常见用例\item[用户名] 用户的登录名广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
\item[超时时间] 最大等待时间(秒)\item[LaTeX] 一种文档准备系统\item[通过] 正确的实现...\item[自动保存] 每 5 分钟自动保存itemize 处理简单列表当项目是统一的列表元素且没有标签时,使用 itemize:
\begin{itemize}
\item 第一个统一项目
\item 第二个统一项目
\item 第三个统一项目
\end{itemize}
enumerate 处理编号步骤或排名当顺序重要时,使用 enumerate:
\begin{enumerate}
\item 流程中的第一步
\item 流程中的第二步
\item 流程中的第三步
\end{enumerate}
在审查或编写 LaTeX 时,寻找这些表明应使用 description 的模式:
\item \textbf{某个标签:} → 应使用 \item[某个标签]\item \emph{某个标签:} → 应使用 \item[某个标签]\item 某个标签 --- → 应使用 \item[某个标签]% 错误
\begin{itemize}
\item \textbf{通过:} \verb|\documentclass{article}|
\item \textbf{失败:} 没有 documentclass 声明
\end{itemize}
% 正确
\begin{description}
\item[通过] \verb|\documentclass{article}|
\item[失败] 没有 documentclass 声明
\end{description}
% 错误
\noindent\textbf{配置:} 将超时时间设置为 30 秒。\\
\textbf{性能:} 针对大型数据集进行了优化。
% 正确
\begin{description}
\item[配置] 将超时时间设置为 30 秒
\item[性能] 针对大型数据集进行了优化
\end{description}
关键:在文学编程文件 (.nw) 中编写 LaTeX 时,使用 noweb 的 [[代码]] 表示法来引用代码,而不是使用 \texttt 并手动转义。
[[代码]] 表示法,而非 \texttt{...\_...}noweb 文学编程系统为代码引用提供了特殊的表示法,可以自动处理下划线等特殊字符。
反模式:使用 \texttt 手动转义下划线
% 错误 - 在 .nw 文件中
The \texttt{get\_submission()} method calls \texttt{\_\_getattribute\_\_}.
We store \texttt{\_original\_get\_submission} in the closure.
The \texttt{NOREFRESH\_GRADES} constant defines final grades.
正确:使用 [[代码]] 表示法
% 正确 - 在 .nw 文件中
The [[get_submission()]] method calls [[__getattribute__]].
We store [[_original_get_submission]] in the closure.
The [[NOREFRESH_GRADES]] constant defines final grades.
为何重要:
[[代码]] 与 \texttt在 .nw 文件中使用 [[代码]] 用于:
[[get_submissions()]], [[__init__]][[_includes]], [[user_id]][[LazySubmission]], [[Assignment]][[NOREFRESH_GRADES]], [[MAX_RETRIES]][[pickle]], [[Canvas]]在 .nw 文件中使用 \texttt 用于:
\texttt{.py}, \texttt{.nw}在常规 .tex 文件中(非文学程序):
\texttt 并正确转义,因为 [[...]] 不可用minted 或 listings 等包来处理代码在审查 .nw 文件时,寻找这些反模式:
\texttt{..._...} → 应使用 [[...]]\texttt{...__...} → 应使用 [[...]]\item[SOME\_CONSTANT 行为] → 应使用更好的标签 + 在文本中使用 [[SOME_CONSTANT]]记录方法:
% 错误
The \texttt{\_\_getstate\_\_} method excludes \texttt{\_original\_get\_submission}.
% 正确
The [[__getstate__]] method excludes [[_original_get_submission]].
记录常量:
% 错误
\item[NOREFRESH\_GRADES 行为] 具有最终成绩的提交...
% 正确
\item[最终成绩政策] 具有最终成绩(A、P、P+、完成)的提交
永远不会被刷新,遵循 [[NOREFRESH_GRADES]] 政策。
记录属性:
% 错误
The decorator adds a \texttt{\_\_cache} dictionary and \texttt{\_\_all\_fetched} flag.
% 正确
The decorator adds a [[__cache]] dictionary and [[__all_fetched]] flag.
\cref{...}(cleveref 包)处理所有交叉引用\S\ref{...} 或手动键入章节/图表前缀\label{sec:介绍} 而非 \label{s1}\cref{sec:背景} → "第 2.1 节"\cref{fig:图表} → "图 3"\cref{tab:结果} → "表 1"\cref{sec:介绍,sec:结论} → "第 1 节和第 4 节"反模式:手动前缀
% 错误
Section~\ref{sec:介绍} 显示...
\S\ref{sec:背景} 讨论...
Figure~\ref{fig:图表} 演示...
% 正确
\cref{sec:介绍} 显示...
\cref{sec:背景} 讨论...
\cref{fig:图表} 演示...
原因:cleveref 包会自动添加正确的前缀(章节、图等),并处理复数形式、范围和特定于语言的格式。
\cite, \citep, \citet),而非手动引用[1] 或 (Smith 2020)\enquote{...} 处理引号,切勿手动使用引号标记\enquote{外层 \enquote{内层} 引号}\begin{displayquote}...\end{displayquote}反模式:手动引号
% 错误
"这是一个引号"
``这是一个引号''
'单引号'
正确:使用 csquotes
% 正确
\enquote{这是一个引号}
\enquote{外层 \enquote{内层} 引号}
原因:手动引号标记无法适应语言设置,并可能导致排版不一致。csquotes 包根据文档语言正确处理所有引号样式。
\emph{...} 来强调单词或短语\textbf{...} 或嵌套的 \emph{\emph{...}}反模式:使用全大写进行强调
% 错误
This is VERY important to understand.
We must do this NOW before moving forward.
The BENEFITS of classes are clear.
正确:语义强调
% 正确
This is \emph{very} important to understand.
We must do this \emph{now} before moving forward.
The \emph{benefits} of classes are clear.
原因:正文中使用全大写被认为是"喊叫"且排版不佳。它更难阅读且看起来不专业。使用 \emph{...} 提供语义强调,LaTeX 将适当地渲染它(通常为斜体,但这可以根据上下文和文档样式进行配置)。
例外:按惯例以大写字母书写的首字母缩略词和专有名称(例如 NASA、USA、PDF)是允许的,不应强调。
核心原则:图像不是图表,但图表可以包含图像。使用带有标题和标签的适当图表和表格环境。
使用 memoir 文档类时,优先使用 sidecaption 而非传统的 \caption,以获得更好的布局和可访问性:
对于图表:
\begin{figure}
\begin{sidecaption}{图像内容的清晰描述}[fig:标签]
\includegraphics[width=0.7\textwidth]{路径/到/图像}
\end{sidecaption}
\end{figure}
对于表格:
\begin{table}
\begin{sidecaption}{表格内容的描述}[tab:标签]
\begin{tabular}{lcc}
\toprule
表头1 & 表头2 & 表头3 \\
\midrule
数据1 & 数据2 & 数据3 \\
\bottomrule
\end{tabular}
\end{sidecaption}
\end{table}
sidecaption 的关键特性:
[fig:标签] 中何时使用 sidecaption:
传统的标题替代方案:
\begin{figure}
\centering
\includegraphics[width=0.7\textwidth]{路径/到/图像}
\caption{图像内容的描述}
\label{fig:标签}
\end{figure}
在以下情况下使用传统的 \caption + \label:
始终使用 \cref{fig:标签}(cleveref 包)来引用图表和表格:
如 \cref{fig:内存层次结构} 所示,辅助内存速度较慢但非易失性。
\cref{tab:基准测试} 中的结果证明...
切勿 硬编码引用,如"图 1"、"表 3.2",或使用手动前缀如 Figure~\ref{fig:标签}——让 cleveref 自动处理编号和前缀。
listings 包处理带有语法高亮的代码\verb 处理内联代码片段figures/图表.pdf 而非 figures\图表.pdf在编写或编辑 LaTeX 内容时:
[[代码]] 表示法,而非 \texttt{...\_...}\textbf{标签:}、.nw 文件中的 \texttt{..._...}检查这些常见问题:
\textbf{标签:} 而非 description 环境的列表\ref\S\ref, Section~\ref, Figure~\ref)而非 \cref\cite 命令"...", '...', ...)而非 \enquote{...}figure 环境的图像对 .nw 文学编程文件的额外检查:
\texttt{..._...} 或 \texttt{...__...} → 应使用 [[...]] 表示法\item[FOO\_BAR 行为] → 使用更好的标签 + 在文本中使用 [[FOO_BAR]][[...]] 替代创建同时生成文章版本的 Beamer 演示文稿时,使用 \mode<presentation> 和 \mode<article> 为每种格式提供适当的内容。
冗长的文本环境:包含超过 2-3 行叙述文字的语义环境(定义、备注、示例、块)对于幻灯片来说过于冗长。
解决方案:为演示文稿提供简洁版本,为文章提供完整解释:
\begin{frame}
\mode<presentation>{%
\begin{remark}[要点]
\begin{itemize}
\item 简洁要点 1
\item 简洁要点 2
\item 简洁要点 3
\end{itemize}
\end{remark}
}
\mode<article>{%
\begin{remark}[要点]
完整的解释性段落,包含详细的推理和上下文,
这些内容会淹没幻灯片,但在书面形式中提供了价值。
额外的段落可以详细阐述细微差别和影响。
\end{remark}
}
\end{frame}
并排布局 使用 \textbytext:
演示文稿:\textbytext(非星号,列宽,适用于 beamer 框架)
文章:\textbytext*(星号,全宽,更适合打印文档)
\begin{frame} \mode<presentation>{% \textbytext{左侧内容}{右侧内容} } \mode<article>{% \textbytext*{左侧内容}{右侧内容} } \end{frame}
幻灯片需要 视觉清晰度 和 简洁性(项目符号、短短语)。文章可以提供 深度 和 解释(完整句子、段落)。为每种媒介设计合适的内容。
对于新的 LaTeX 文档,使用 references/preamble.tex 中的标准导言区。将其逐字复制到项目的 doc/preamble.tex 中,并在 \documentclass 之后使用 \input{preamble} 包含它。
文档结构:
\documentclass[a4paper,oneside]{memoir}
\input{preamble}
\title{文档标题}
\author{作者姓名}
\date{\today}
\begin{document}
\frontmatter
\maketitle
\tableofcontents
\mainmatter
% 内容在此
\backmatter
\end{document}
标准导言区提供:
这确保了所有文档和项目之间格式的一致性。
LaTeX 是一个基于 语义标记 的 文档准备系统,而非文字处理器。目标是描述内容 是什么,而不是它应该 看起来如何。让 LaTeX 根据您提供的语义结构来处理格式化。
每周安装次数
31
仓库
GitHub 星标数
1
首次出现
2026 年 1 月 28 日
安全审计
安装于
opencode27
gemini-cli26
cursor24
claude-code23
codex23
github-copilot22
This skill guides the creation of well-structured, semantically correct LaTeX documents following established best practices.
Use LaTeX environments that match the semantic meaning of the content, not just the visual appearance.
description for Term-Definition PairsWhen you have labels followed by explanations, definitions, or descriptions, use the description environment:
\begin{description}
\item[Term] Definition or explanation of the term
\item[Label] Content associated with the label
\item[Property] Description of the property
\end{description}
NEVER do this:
\begin{itemize}
\item \textbf{Term:} Definition or explanation
\item \textbf{Label:} Content associated with label
\end{itemize}
description\item[username] The user's login name\item[timeout] Maximum wait time in seconds\item[LaTeX] A document preparation system\item[Passes] Correct implementation...\item[Auto-save] Automatically saves every 5 minutesitemize for Simple ListsUse itemize when items are uniform list elements without labels:
\begin{itemize}
\item First uniform item
\item Second uniform item
\item Third uniform item
\end{itemize}
enumerate for Numbered Steps or RankingsUse enumerate when order matters:
\begin{enumerate}
\item First step in the process
\item Second step in the process
\item Third step in the process
\end{enumerate}
When reviewing or writing LaTeX, look for these patterns that indicate description should be used:
\item \textbf{SomeLabel:} → Should use \item[SomeLabel]\item \emph{SomeLabel:} → Should use \item[SomeLabel]\item SomeLabel --- → Should use \item[SomeLabel]% INCORRECT
\begin{itemize}
\item \textbf{Passes:} \verb|\documentclass{article}|
\item \textbf{Fails:} No documentclass declaration
\end{itemize}
% CORRECT
\begin{description}
\item[Passes] \verb|\documentclass{article}|
\item[Fails] No documentclass declaration
\end{description}
% INCORRECT
\noindent\textbf{Configuration:} Set timeout to 30 seconds.\\
\textbf{Performance:} Optimized for large datasets.
% CORRECT
\begin{description}
\item[Configuration] Set timeout to 30 seconds
\item[Performance] Optimized for large datasets
\end{description}
CRITICAL : When writing LaTeX in literate programming files (.nw), use noweb's [[code]] notation for quoting code, not \texttt with manual escaping.
[[code]] Notation, Not \texttt{...\_...}The noweb literate programming system provides special notation for code references that automatically handles special characters like underscores.
Anti-pattern : Manual underscore escaping with \texttt
% INCORRECT - in .nw files
The \texttt{get\_submission()} method calls \texttt{\_\_getattribute\_\_}.
We store \texttt{\_original\_get\_submission} in the closure.
The \texttt{NOREFRESH\_GRADES} constant defines final grades.
Correct : Use [[code]] notation
% CORRECT - in .nw files
The [[get_submission()]] method calls [[__getattribute__]].
We store [[_original_get_submission]] in the closure.
The [[NOREFRESH_GRADES]] constant defines final grades.
Why this matters :
[[code]] vs \textttUse[[code]] in .nw files for:
[[get_submissions()]], [[__init__]][[_includes]], [[user_id]][[LazySubmission]], [[Assignment]][[NOREFRESH_GRADES]], [[MAX_RETRIES]][[pickle]], [[Canvas]]Use\texttt in .nw files for:
\texttt{.py}, \texttt{.nw}In regular .tex files (not literate programs):
\texttt with proper escaping as [[...]] is not availableminted or listings for codeWhen reviewing .nw files, look for these anti-patterns:
\texttt{..._...} → Should use [[...]]\texttt{...__...} → Should use [[...]]\item[SOME\_CONSTANT behavior] → Should use better label + [[SOME_CONSTANT]] in textDocumenting methods:
% INCORRECT
The \texttt{\_\_getstate\_\_} method excludes \texttt{\_original\_get\_submission}.
% CORRECT
The [[__getstate__]] method excludes [[_original_get_submission]].
Documenting constants:
% INCORRECT
\item[NOREFRESH\_GRADES behavior] Submissions with final grades...
% CORRECT
\item[Final grade policy] Submissions with final grades (A, P, P+, complete)
are never refreshed, maintaining the [[NOREFRESH_GRADES]] policy.
Documenting attributes:
% INCORRECT
The decorator adds a \texttt{\_\_cache} dictionary and \texttt{\_\_all\_fetched} flag.
% CORRECT
The decorator adds a [[__cache]] dictionary and [[__all_fetched]] flag.
\cref{...} (cleveref package) for all cross-references\S\ref{...} or manually type section/figure prefixes\label{sec:introduction} not \label{s1}\cref{sec:background} → "Section 2.1"\cref{fig:diagram} → "Figure 3"\cref{tab:results} → "Table 1"\cref{sec:intro,sec:conclusion} → "Sections 1 and 4"Anti-pattern : Manual prefixes
% INCORRECT
Section~\ref{sec:intro} shows...
\S\ref{sec:background} discusses...
Figure~\ref{fig:plot} demonstrates...
% CORRECT
\cref{sec:intro} shows...
\cref{sec:background} discusses...
\cref{fig:plot} demonstrates...
Why : The cleveref package automatically adds the correct prefix (Section, Figure, etc.) and handles pluralization, ranges, and language-specific formatting.
\cite, \citep, \citet) not manual references[1] or (Smith 2020) manually\enquote{...} for quotes, never manual quote marks\enquote{outer \enquote{inner} quote}\begin{displayquote}...\end{displayquote}Anti-pattern : Manual quotes
% INCORRECT
"This is a quote"
``This is a quote''
'single quotes'
Correct : Use csquotes
% CORRECT
\enquote{This is a quote}
\enquote{outer \enquote{inner} quote}
Why : Manual quote marks don't adapt to language settings and can cause typographical inconsistencies. The csquotes package handles all quote styling correctly based on document language.
\emph{...} to emphasize words or phrases\textbf{...} or nested \emph{\emph{...}}Anti-pattern : ALL CAPITALS for emphasis
% INCORRECT
This is VERY important to understand.
We must do this NOW before moving forward.
The BENEFITS of classes are clear.
Correct : Semantic emphasis
% CORRECT
This is \emph{very} important to understand.
We must do this \emph{now} before moving forward.
The \emph{benefits} of classes are clear.
Why : ALL CAPITALS in running text is considered shouting and poor typography. It's harder to read and looks unprofessional. Use \emph{...} to provide semantic emphasis, and LaTeX will render it appropriately (typically as italics, but this can be configured based on context and document style).
Exception : Acronyms and proper names that are conventionally written in capitals (e.g., NASA, USA, PDF) are fine and should not be emphasized.
Core principle : An image is not a figure, but a figure can contain an image. Use proper figure and table environments with captions and labels.
When using the memoir document class, prefer sidecaption over traditional \caption for better layout and accessibility:
For figures:
\begin{figure}
\begin{sidecaption}{Clear description of image content}[fig:label]
\includegraphics[width=0.7\textwidth]{path/to/image}
\end{sidecaption}
\end{figure}
For tables:
\begin{table}
\begin{sidecaption}{Description of table content}[tab:label]
\begin{tabular}{lcc}
\toprule
Header1 & Header2 & Header3 \\
\midrule
Data1 & Data2 & Data3 \\
\bottomrule
\end{tabular}
\end{sidecaption}
\end{table}
Key features of sidecaption:
[fig:label]When to use sidecaption:
Traditional caption alternative:
\begin{figure}
\centering
\includegraphics[width=0.7\textwidth]{path/to/image}
\caption{Description of image content}
\label{fig:label}
\end{figure}
Use traditional \caption + \label when:
Always use \cref{fig:label} (cleveref package) to reference figures and tables:
As shown in \cref{fig:memory-hierarchy}, secondary memory is slower but non-volatile.
The results in \cref{tab:benchmark} demonstrate...
Never hard-code references like "Figure 1", "Table 3.2", or use manual prefixes like Figure~\ref{fig:label}—let cleveref handle both numbering and prefixes automatically.
listings package for code with syntax highlighting\verb for inline code snippetsfigures/diagram.pdf not figures\diagram.pdfWhen writing or editing LaTeX content:
[[code]] notation, not \texttt{...\_...}\textbf{Label:} in itemize, \texttt{..._...} in .nw filesCheck for these common issues:
\textbf{Label:} instead of description environment\ref\S\ref, Section~\ref, Figure~\ref) instead of \cref\cite commands"...", '...', ...) instead of Additional checks for .nw literate programming files:
\texttt{..._...} or \texttt{...__...} → Should use [[...]] notation\item[FOO\_BAR behavior] → Use better label + [[FOO_BAR]] in text[[...]] insteadWhen creating Beamer presentations that also generate article versions, use \mode<presentation> and \mode<article> to provide appropriate content for each format.
Verbose text environments : Semantic environments (definition, remark, example, block) with more than 2-3 lines of prose are too verbose for slides.
Solution : Provide concise versions for presentations and full explanations for articles:
\begin{frame}
\mode<presentation>{%
\begin{remark}[Key Point]
\begin{itemize}
\item Concise point 1
\item Concise point 2
\item Concise point 3
\end{itemize}
\end{remark}
}
\mode<article>{%
\begin{remark}[Key Point]
Full explanatory paragraph with detailed reasoning and context
that would overwhelm a slide but provides value in written form.
Additional paragraphs can elaborate on nuances and implications.
\end{remark}
}
\end{frame}
Side-by-side layouts using \textbytext:
Presentation: \textbytext (non-starred, column width, works in beamer frames)
Article: \textbytext* (starred, fullwidth, better for printed documents)
\begin{frame} \mode<presentation>{% \textbytext{Left content}{Right content} } \mode<article>{% \textbytext*{Left content}{Right content} } \end{frame}
Slides need visual clarity and conciseness (bullets, short phrases). Articles can provide depth and explanation (full sentences, paragraphs). Design content appropriate for each medium.
For new LaTeX documents, use the standard preamble from references/preamble.tex. Copy it verbatim to your project's doc/preamble.tex and include it with \input{preamble} after \documentclass.
Document structure:
\documentclass[a4paper,oneside]{memoir}
\input{preamble}
\title{Document Title}
\author{Author Name}
\date{\today}
\begin{document}
\frontmatter
\maketitle
\tableofcontents
\mainmatter
% Content here
\backmatter
\end{document}
The standard preamble provides:
This ensures consistent formatting across all documents and projects.
LaTeX is a document preparation system based on semantic markup , not a word processor. The goal is to describe what content is , not how it should look. Let LaTeX handle the formatting based on the semantic structure you provide.
Weekly Installs
31
Repository
GitHub Stars
1
First Seen
Jan 28, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode27
gemini-cli26
cursor24
claude-code23
codex23
github-copilot22
文档查找工具:实时获取库、框架和API最新文档,替代训练数据
1,200 周安装
\enquote{...}figure environment