สร้างเอกสารด้วย LaTeX ผ่าน Claude AI
May 2026 · Peerapat A · ← Agentic AI
Writing LaTeX Documents with Claude AI
Bottom Line Up Front: XeLaTeX is required to render Thai fonts (like TH Sarabun New) properly. By combining a custom document class with Claude AI and a clear CLAUDE.md instruction file, you can easily generate professional, reusable Thai enterprise reports.
LaTeX is still my go-to for any serious document — especially when it needs to look professional, handle Thai text correctly, and be reusable across projects. In this post I walk through how I built template-doc, a custom LaTeX template for Thai-language enterprise reports, and how Claude became an essential part of that workflow.
The Problem with Thai in LaTeX
Standard LaTeX (pdflatex) cannot render Thai script. You need XeLaTeX, which supports Unicode and OpenType fonts natively.
The template is built around the TH Sarabun New font — a clean, readable Thai typeface — loaded via
Project Structure
The repository follows a modular layout to keep large documents manageable:
template-doc/
├── main.tex # Entry point — includes all sections
├── easreport.cls # Custom document class (Thai fonts, headers, layout)
├── conf/
│ └── latexmkrc # Build config: XeLaTeX engine, out/ output dir
├── sections/ # One .tex file per section
│ ├── title.tex
│ ├── togaf.tex
│ ├── a_vision.tex
│ ├── b_business.tex
│ ├── c_system.tex
│ ├── d_technology.tex
│ ├── e_opportunities.tex
│ ├── f_migration.tex
│ ├── g_security_er.tex
│ ├── overview.tex
│ ├── security.tex
│ └── install.tex
├── figures/ # Images referenced in sections
└── assets/ # Watermark and other assets
Each section is an independent
The Custom Class: easreport.cls
The heart of the template is
- fontspec + xunicode — Unicode font management for Thai script
- TH Sarabun New — primary font configured for Thai and Latin text
- microtype — advanced typographic enhancements
- geometry — A4 page with 1" top/bottom and 0.7" side margins
- fancyhdr — header and footer with organization name, document title, and page numbers
- tabularx, booktabs, longtable — professional table formatting
- hyperref — clickable links with hidden borders
- hyphenat + ragged2e — hyphenation control for mixed Thai-English content
The class also defines custom metadata commands —
Building the PDF
The build uses latexmk with a project-local config file:
# Build PDF
latexmk -r conf/latexmkrc main.tex
# Clean build artifacts
latexmk -r conf/latexmkrc -C main.tex
How I Work with Claude on LaTeX
The repository includes a
Key rules in
- Always target XeLaTeX — pdflatex will fail because fontspec is required for Thai
- Use
\[ ... \] oralign environments for display math, not$$ - Escape special LaTeX characters when they appear as literal text
- Prefer semantic markup:
\emph{} over\textit{} - Place
\microtypecontext{spacing=nonadjacent} in the preamble when using microtype with Thai fonts - Use
\sloppy /\fussy in sections to control Thai text line-breaking
Practical Workflow
My day-to-day flow when writing a section with Claude:
- Open a section file — e.g.,
sections/d_technology.tex - Describe the content to Claude in plain language — what the section covers, what diagrams exist in
figures/ - Claude drafts the LaTeX — using the class's custom commands, correct Thai font handling, and proper table/figure environments
- Build and review —
latexmk -r conf/latexmkrc main.tex and openout/main.pdf - Iterate — paste compilation errors back to Claude for targeted fixes
The modular section structure is key here. Claude only needs to see one
Gotchas Worth Knowing
-
XeLaTeX is mandatory. Running pdflatex will immediately fail on
\usepackage{fontspec} . Always confirm the engine in your build config. - TH Sarabun New must be installed. On macOS/Linux, install it as a system font before building. CI environments often need an explicit font installation step.
-
microtype + Thai needs a config line. Add
\microtypecontext{spacing=nonadjacent} to suppress warnings and prevent spacing conflicts with Thai characters. -
Line-breaking Thai text is tricky. Use
\sloppy generously in sections with dense Thai prose to avoid overfull hbox warnings.
Why This Approach Works
Pairing LaTeX's precision with Claude's natural language interface removes the friction of remembering every command and environment.
I describe what I need in Thai or English, Claude generates correct LaTeX against a well-defined template, and I compile immediately to verify.
The
The template is open on GitHub at nuboat/template-doc.
Clone it, add your own sections, and point Claude at your
Note: This blog post was written with Claude Code using the template-doc repository as source material.
สร้างเอกสารด้วย LaTeX ผ่าน Claude AI
สรุปประเด็นสำคัญ (BLUF): การพิมพ์ภาษาไทยใน LaTeX ต้องใช้ XeLaTeX ควบคู่กับฟอนต์ TH Sarabun New การนำ custom document class มาทำงานร่วมกับ Claude AI และไฟล์ CLAUDE.md จะช่วยให้คุณสร้างรายงานระดับองค์กรภาษาไทยที่ดูเป็นมืออาชีพได้อย่างรวดเร็ว
LaTeX ยังคงเป็นเครื่องมือคู่ใจของผมสำหรับ document ใดๆ ที่มีความสำคัญ — โดยเฉพาะเมื่อมันจำเป็นต้องดูมีความเป็น professional, สามารถจัดการกับภาษาไทยได้อย่างถูกต้อง, และสามารถนำกลับมาใช้ใหม่ (reusable) ข้าม projects ได้ ในบทความนี้ ผมจะพาทุกคนไปดูว่าผมสร้าง template-doc ขึ้นมาได้อย่างไร, ซึ่งเป็น custom LaTeX template สำหรับ enterprise reports ภาษาไทย, และ Claude กลายมาเป็นส่วนสำคัญอย่างขาดไม่ได้ใน workflow นั้นได้อย่างไร
ปัญหาของการพิมพ์ภาษาไทยใน LaTeX
Standard LaTeX (pdflatex) ไม่สามารถ render ภาษาไทยได้ คุณจำเป็นต้องใช้ XeLaTeX ซึ่งรองรับ Unicode และ OpenType fonts ได้แบบ natively ตัว template ถูกสร้างขึ้นมาโดยอิงจาก font TH Sarabun New — ซึ่งเป็น typeface ภาษาไทยที่ดูสะอาดและอ่านง่าย — โดยทำการ load ผ่าน
Project Structure
Repository นี้ใช้การวางโครงสร้างแบบ modular เพื่อให้จัดการ documents ขนาดใหญ่ได้ง่าย:
template-doc/
├── main.tex # Entry point — includes all sections
├── easreport.cls # Custom document class (Thai fonts, headers, layout)
├── conf/
│ └── latexmkrc # Build config: XeLaTeX engine, out/ output dir
├── sections/ # One .tex file per section
│ ├── title.tex
│ ├── togaf.tex
│ ├── a_vision.tex
│ ├── b_business.tex
│ ├── c_system.tex
│ ├── d_technology.tex
│ ├── e_opportunities.tex
│ ├── f_migration.tex
│ ├── g_security_er.tex
│ ├── overview.tex
│ ├── security.tex
│ └── install.tex
├── figures/ # Images referenced in sections
└── assets/ # Watermark and other assets
แต่ละส่วนจะเป็นไฟล์
The Custom Class: easreport.cls
หัวใจสำคัญของ template นี้คือ
- fontspec + xunicode — การจัดการ Unicode font สำหรับภาษาไทย
- TH Sarabun New — font หลักที่ถูกตั้งค่าไว้สำหรับข้อความภาษาไทยและอักษรละติน
- microtype — การปรับปรุงความสวยงามของการจัดพิมพ์ (typographic enhancements) ขั้นสูง
- geometry — หน้ากระดาษ A4 ที่มี margin ด้านบน/ล่าง 1 นิ้ว และด้านข้าง 0.7 นิ้ว
- fancyhdr — header และ footer พร้อมกับชื่อองค์กร, ชื่อ document, และหมายเลขหน้า
- tabularx, booktabs, longtable — การจัดรูปแบบตารางอย่างมืออาชีพ
- hyperref — clickable links ที่ซ่อนเส้นขอบ
- hyphenat + ragged2e — การควบคุม hyphenation สำหรับเนื้อหาภาษาไทยผสมภาษาอังกฤษ
Class นี้ยังมีการกำหนด custom metadata commands ด้วย —
Building the PDF
การ build จะใช้ latexmk ร่วมกับ project-local config file:
# Build PDF
latexmk -r conf/latexmkrc main.tex
# Clean build artifacts
latexmk -r conf/latexmkrc -C main.tex
วิธีที่ผมทำงานกับ Claude บน LaTeX
Repository นี้จะมีไฟล์
กฎสำคัญใน
- ต้องกำหนดเป้าหมายเป็น XeLaTeX เสมอ — การใช้ pdflatex จะเกิด fail เนื่องจากเราต้องการ fontspec สำหรับภาษาไทย
- ใช้ environments อย่าง
\[ ... \] หรือalign สำหรับการทำ display math ไม่ใช่$$ - ต้อง escape ตัวอักษรพิเศษของ LaTeX ทุกครั้งเมื่อใช้เป็นข้อความปกติ (literal text)
- เลือกใช้ semantic markup: อย่าง
\emph{} แทน\textit{} - ใส่
\microtypecontext{spacing=nonadjacent} ใน preamble เมื่อใช้งาน microtype ร่วมกับ font ภาษาไทย - ใช้
\sloppy /\fussy ภายใน sections เพื่อควบคุมเรื่อง line-breaking สำหรับข้อความภาษาไทย
Practical Workflow
Workflow แบบวันต่อวันเมื่อต้องเขียนแต่ละ section ร่วมกับ Claude:
- เปิดไฟล์ section — เช่น,
sections/d_technology.tex - อธิบายรายละเอียดเนื้อหา ให้ Claude ฟังด้วยภาษาพูดธรรมดา — บอกว่า section นี้เกี่ยวกับอะไร, มี diagrams อะไรบ้างใน
figures/ - Claude จะเริ่ม draft เป็น LaTeX — โดยใช้ custom commands ของ class, การจัดการ font ภาษาไทยที่ถูกต้อง, รวมไปถึงการเลือกใช้ table/figure environments อย่างเหมาะสม
- Build และ ตรวจทาน (review) — รัน
latexmk -r conf/latexmkrc main.tex และเปิดไฟล์out/main.pdf - ทำซ้ำ (Iterate) — ถ้านำมา compile แล้วเจอ error ให้ copy กลับไปให้ Claude เพื่อแก้ไขเฉพาะจุดที่พัง
โครงสร้างแบบ modular section คือส่วนสำคัญอย่างยิ่ง Claude จะมองเห็นไฟล์
Gotchas ที่ควรรู้
-
XeLaTeX จำเป็นต้องใช้เสมอ การใช้ pdflatex จะทำให้การ compile ล้มเหลวทันทีที่
\usepackage{fontspec} อย่าลืมตรวจสอบ engine ภายใน build config ก่อนเสมอ - TH Sarabun New จะต้องถูก install ก่อน บน macOS/Linux, ให้ทำการ install font นี้เป็น system font ก่อนสั่ง building สำหรับบนสภาพแวดล้อมแบบ CI ก็มักจำเป็นต้องมีขั้นตอนการ install font แบบ explicit ด้วยเช่นกัน
-
microtype + Thai ต้องการ config line เพิ่ม
\microtypecontext{spacing=nonadjacent} เพื่อซ่อนข้อความเตือนและหลีกเลี่ยงปัญหาเรื่อง spacing กับการใช้ตัวอักษรไทย -
การทำ line-breaking สำหรับข้อความภาษาไทยนั้นเป็นเรื่องที่ยุ่งยาก พยายามใช้
\sloppy บ่อยๆ ภายใน sections ที่มีข้อความภาษาไทยจำนวนมาก เพื่อหลีกเลี่ยงการเจอ overfull hbox warnings
Why This Approach Works
การรวมความแม่นยำของ LaTeX เข้ากับ interface ที่พูดคุยผ่านภาษาธรรมชาติของ Claude ช่วยขจัดความเหนื่อยล้าในการที่ต้องคอยจำทุก command และทุก environment ไปได้ ผมแค่อธิบายสิ่งที่ผมต้องการในภาษาไทยหรือภาษาอังกฤษ จากนั้น Claude ก็จะทำการ generate LaTeX อย่างถูกต้องตาม template ที่ได้ถูกออกแบบไว้ และผมก็สามารถ compile ดูผลได้ทันที
ไฟล์
ตัว template ถูกเปิดไว้เป็น open source บน GitHub ที่ nuboat/template-doc คุณสามารถ clone มัน, เพิ่มเนื้อหาในส่วนต่างๆ เข้าไป และชี้เป้าให้ Claude ศึกษาจากไฟล์
Note: บทความบน blog นี้ ถูกเขียนร่วมกับ Claude Code โดยได้อ้างอิง source material มาจาก template-doc repository
使用 Claude AI 编写 LaTeX 文档
核心结论 (BLUF): 必须使用 XeLaTeX 才能正确渲染泰文。通过将自定义的 document class 与 Claude AI 以及清晰的 CLAUDE.md 指令文件结合使用,您可以轻松生成专业的泰文企业报告。
LaTeX 仍然是我处理任何重要 document 的首选——尤其是当它需要看起来很 professional、能够正确处理泰文文本,并且可以在不同 projects 之间 reusable 时。 在这篇文章中,我将逐步介绍我是如何构建 template-doc 的, 这是一个用于泰文 enterprise reports 的 custom LaTeX template,以及 Claude 是如何成为该 workflow 中不可或缺的一部分的。
在 LaTeX 中处理泰文的 Problem
Standard LaTeX (pdflatex) 无法 render 泰文。你需要使用 XeLaTeX,它 natively 支持 Unicode 和 OpenType fonts。
该 template 是围绕 TH Sarabun New font 构建的——这是一种干净、易读的泰文 typeface——通过
Project Structure
该 repository 采用了 modular 的布局,以便使大型 documents 易于管理:
template-doc/
├── main.tex # Entry point — includes all sections
├── easreport.cls # Custom document class (Thai fonts, headers, layout)
├── conf/
│ └── latexmkrc # Build config: XeLaTeX engine, out/ output dir
├── sections/ # One .tex file per section
│ ├── title.tex
│ ├── togaf.tex
│ ├── a_vision.tex
│ ├── b_business.tex
│ ├── c_system.tex
│ ├── d_technology.tex
│ ├── e_opportunities.tex
│ ├── f_migration.tex
│ ├── g_security_er.tex
│ ├── overview.tex
│ ├── security.tex
│ └── install.tex
├── figures/ # Images referenced in sections
└── assets/ # Watermark and other assets
每一个 section 都是一个独立的
The Custom Class: easreport.cls
该 template 的核心是
- fontspec + xunicode — 泰文脚本的 Unicode font 管理
- TH Sarabun New — 配置为泰文和拉丁文本的主要 font
- microtype — 高级排版增强功能 (typographic enhancements)
- geometry — 上下 margin 1 英寸,侧边 margin 0.7 英寸的 A4 页面
- fancyhdr — 包含组织名称、document 标题和页码的 header 和 footer
- tabularx, booktabs, longtable — professional 表格格式化
- hyperref — 隐藏边框的 clickable links
- hyphenat + ragged2e — 用于泰文-英文混合内容的 hyphenation 控制
该 class 还定义了 custom metadata commands——
Building the PDF
构建过程使用 latexmk 并配合 project-local 的 config 文件:
# Build PDF
latexmk -r conf/latexmkrc main.tex
# Clean build artifacts
latexmk -r conf/latexmkrc -C main.tex
我如何与 Claude 在 LaTeX 上合作
该 repository 包含一个
- 必须始终 target XeLaTeX——使用 pdflatex 会失败,因为泰文需要 fontspec
- 使用
\[ ... \] 或align environments 来编写 display math,而不是使用$$ - 当特殊的 LaTeX 字符作为 literal text 出现时,必须对其进行 escape 处理
- 首选 semantic markup:例如,优先使用
\emph{} 而不是\textit{} - 当泰文 fonts 配合 microtype 使用时,在 preamble 中添加
\microtypecontext{spacing=nonadjacent} - 在包含大量泰文的 sections 中使用
\sloppy /\fussy 来控制 line-breaking
Practical Workflow
当我和 Claude 一起编写一个 section 时的 day-to-day workflow:
- 打开一个 section 文件——例如,
sections/d_technology.tex - 用口语向 Claude 描述内容——说明该 section 涵盖什么内容,以及
figures/ 中有哪些 diagrams - Claude 起草 LaTeX——使用 class 的 custom commands,正确处理泰文 font,并使用适当的 table/figure environments
- Build 并进行 review——运行
latexmk -r conf/latexmkrc main.tex 并打开out/main.pdf - 迭代 (Iterate)——将编译 error 粘贴回给 Claude,以进行针对性的修复
modular 的 section 结构在这里起到了关键作用。Claude 一次只需要查看一个
值得注意的 Gotchas
-
XeLaTeX 是必须的。 如果运行 pdflatex,会立即在
\usepackage{fontspec} 处失败。 请务必在 build config 中确认你的 engine。 - 必须安装 TH Sarabun New。 在 macOS/Linux 上,请在 building 前将其作为 system font 安装。 CI 环境通常需要一个显式的 font 安装步骤。
-
microtype + 泰文需要一行 config。 添加
\microtypecontext{spacing=nonadjacent} 可以抑制警告并防止与泰文字符发生 spacing 冲突。 -
泰文文本的 line-breaking 很难处理。 在包含密集泰文散文的 sections 中,应多使用
\sloppy 以避免出现 overfull hbox 警告。
Why This Approach Works
将 LaTeX 的精确性与 Claude 的自然语言 interface 结合起来,消除了记忆每一个 command 和 environment 的摩擦。
我只需要用泰文或英文描述我需要什么,Claude 就会根据一个定义良好的 template 生成正确的 LaTeX,然后我可以直接编译来验证。
该 template 已在 GitHub 上的 nuboat/template-doc 开源。
将其 clone 下来,添加你自己的 sections,并让 Claude 阅读你的
Note: 这篇 blog post 是在 Claude Code 的帮助下,使用 template-doc repository 作为 source material 编写的。
Claude AI を使った LaTeX ドキュメントの作成
要点 (BLUF): タイ語フォントを正しくレンダリングするには XeLaTeX が必要です。カスタム document class と Claude AI、そして明確な CLAUDE.md を組み合わせることで、プロフェッショナルなタイ語の企業向けレポートを簡単に作成できます。
LaTeX は、いまでも本格的な document を作成するための私の頼れるツールです。特に professional な見た目が必要な時や、タイ語のテキストを正しく処理し、複数の projects 間で reusable にする必要がある場合はそうです。 この記事では、私がタイ語の enterprise reports 用の custom LaTeX template である template-doc をどのように構築したか、そして Claude がその workflow においてどのように不可欠な存在となったかについて解説します。
LaTeX におけるタイ語の Problem
Standard LaTeX (pdflatex) はタイ語を render できません。Unicode と OpenType fonts を natively にサポートする XeLaTeX が必要です。
この template は、すっきりと読みやすいタイ語の typeface である TH Sarabun New font をベースに構築されており、
Project Structure
この repository は、大規模な documents を管理しやすくするために、modular なレイアウトを採用しています:
template-doc/
├── main.tex # Entry point — includes all sections
├── easreport.cls # Custom document class (Thai fonts, headers, layout)
├── conf/
│ └── latexmkrc # Build config: XeLaTeX engine, out/ output dir
├── sections/ # One .tex file per section
│ ├── title.tex
│ ├── togaf.tex
│ ├── a_vision.tex
│ ├── b_business.tex
│ ├── c_system.tex
│ ├── d_technology.tex
│ ├── e_opportunities.tex
│ ├── f_migration.tex
│ ├── g_security_er.tex
│ ├── overview.tex
│ ├── security.tex
│ └── install.tex
├── figures/ # Images referenced in sections
└── assets/ # Watermark and other assets
各 section は独立した
The Custom Class: easreport.cls
この template の核心は
- fontspec + xunicode — タイ文字のための Unicode font 管理
- TH Sarabun New — タイ語およびラテン文字用に設定されたプライマリ font
- microtype — 高度なタイポグラフィ強化 (typographic enhancements)
- geometry — 上下 1インチ、左右 0.7インチの margin を持つ A4 ページ
- fancyhdr — 組織名、document タイトル、ページ番号を含む header と footer
- tabularx, booktabs, longtable — professional なテーブルフォーマット
- hyperref — 境界線を隠した clickable links
- hyphenat + ragged2e — タイ語・英語混在コンテンツの hyphenation コントロール
この class では custom metadata commands(
Building the PDF
ビルドには project-local の config ファイルとともに latexmk を使用します:
# Build PDF
latexmk -r conf/latexmkrc main.tex
# Clean build artifacts
latexmk -r conf/latexmkrc -C main.tex
LaTeX での Claude との働き方
この repository には
- 常に XeLaTeX を target にする — タイ語には fontspec が必要なため、pdflatex では失敗します
- display math には
$$ ではなく\[ ... \] またはalign environments を使用する - 特別な LaTeX 文字が literal text として表示される場合はエスケープする
- semantic markup を優先する:
\textit{} よりも\emph{} - タイ語 fonts で microtype を使用する場合は、preamble に
\microtypecontext{spacing=nonadjacent} を配置する - タイ語テキストの line-breaking を制御するには、sections 内で
\sloppy /\fussy を使用する
Practical Workflow
Claude と section を書くときの日々の workflow は次のとおりです:
- section ファイルを開く — 例:
sections/d_technology.tex - 内容を説明する — その section で何を取り上げるか、
figures/ にどのような diagrams があるかなどを平易な言葉で Claude に伝えます - Claude が LaTeX をドラフトする — class の custom commands、正しいタイ語 font の扱い、適切な table/figure environments を使用します
- Build とレビュー —
latexmk -r conf/latexmkrc main.tex を実行し、out/main.pdf を開きます - 反復 (Iterate) — コンパイル error を Claude にペーストし、的を絞った修正を行います
ここでは、modular な section 構造が鍵となります。Claude は一度に1つの
知っておくべき Gotchas
-
XeLaTeX は必須です。 pdflatex を実行すると、
\usepackage{fontspec} で直ちに失敗します。 build config で常に engine を確認してください。 - TH Sarabun New をインストールする必要があります。 macOS/Linux では、building 前に system font としてインストールしてください。 CI 環境では多くの場合、明示的な font インストールステップが必要です。
-
microtype + タイ語には config 行が必要です。 警告を抑制し、タイ文字との spacing の競合を防ぐために
\microtypecontext{spacing=nonadjacent} を追加します。 -
タイ語の line-breaking は厄介です。 overfull hbox 警告を避けるために、密なタイ語の散文がある sections では
\sloppy を惜しみなく使用してください。
Why This Approach Works
LaTeX の正確さと Claude の自然言語 interface を組み合わせることで、すべての command や environment を覚える摩擦がなくなります。
タイ語や英語で必要なものを説明するだけで、Claude が明確に定義された template に対して正しい LaTeX を生成し、私はすぐにコンパイルして確認できます。
この template は GitHub の nuboat/template-doc でオープンになっています。
これを clone し、独自の sections を追加して、Claude にあなたの
Note: この blog post は、template-doc repository を source material として使用し、Claude Code で執筆されました。
LaTeX-Dokumente mit Claude AI schreiben
Zusammenfassung (BLUF): XeLaTeX ist erforderlich, um thailändische Schriftarten korrekt zu rendern. Durch die Kombination einer benutzerdefinierten Dokumentenklasse mit Claude AI und einer klaren CLAUDE.md-Datei können Sie problemlos professionelle thailändische Unternehmensberichte erstellen.
LaTeX ist immer noch meine erste Wahl für jedes ernsthafte document – besonders dann, wenn es professional aussehen, thailändischen Text korrekt verarbeiten und über verschiedene projects hinweg reusable sein muss. In diesem Beitrag zeige ich, wie ich template-doc entwickelt habe, ein custom LaTeX template für thailändische enterprise reports, und wie Claude zu einem unverzichtbaren Teil dieses workflows wurde.
Das Problem mit Thai in LaTeX
Standard LaTeX (pdflatex) kann die thailändische Schrift nicht rendern. Sie benötigen XeLaTeX, das Unicode und OpenType fonts natively unterstützt.
Das template baut auf der font TH Sarabun New auf – einem klaren, gut lesbaren thailändischen typeface – der über
Project Structure
Das repository folgt einem modular aufgebauten Layout, um große documents verwaltbar zu halten:
template-doc/
├── main.tex # Entry point — includes all sections
├── easreport.cls # Custom document class (Thai fonts, headers, layout)
├── conf/
│ └── latexmkrc # Build config: XeLaTeX engine, out/ output dir
├── sections/ # One .tex file per section
│ ├── title.tex
│ ├── togaf.tex
│ ├── a_vision.tex
│ ├── b_business.tex
│ ├── c_system.tex
│ ├── d_technology.tex
│ ├── e_opportunities.tex
│ ├── f_migration.tex
│ ├── g_security_er.tex
│ ├── overview.tex
│ ├── security.tex
│ └── install.tex
├── figures/ # Images referenced in sections
└── assets/ # Watermark and other assets
Jeder section ist eine unabhängige
The Custom Class: easreport.cls
Das Herzstück des template ist
- fontspec + xunicode — Unicode font Management für die thailändische Schrift
- TH Sarabun New — die primäre font, konfiguriert für thailändischen und lateinischen Text
- microtype — fortgeschrittene typografische Verbesserungen (typographic enhancements)
- geometry — A4-Seite mit 1 Zoll margin oben/unten und 0,7 Zoll seitlichen margins
- fancyhdr — header und footer mit Organisationsname, document Titel und Seitenzahlen
- tabularx, booktabs, longtable — professional Tabellenformatierung
- hyperref — clickable links mit versteckten Rändern
- hyphenat + ragged2e — hyphenation Kontrolle für gemischte thailändisch-englische Inhalte
Die class definiert außerdem custom metadata commands —
Building the PDF
Für den Build wird latexmk mit einer project-local config Datei verwendet:
# Build PDF
latexmk -r conf/latexmkrc main.tex
# Clean build artifacts
latexmk -r conf/latexmkrc -C main.tex
Wie ich mit Claude an LaTeX arbeite
Das repository enthält eine
Wichtige Regeln in
- Zielen Sie immer auf XeLaTeX ab – pdflatex wird fehlschlagen, da fontspec für Thai erforderlich ist
- Verwenden Sie
\[ ... \] oderalign environments für display math, nicht$$ - Escapen Sie spezielle LaTeX-Zeichen, wenn sie als literal text erscheinen
- Bevorzugen Sie semantic markup:
\emph{} gegenüber\textit{} - Platzieren Sie
\microtypecontext{spacing=nonadjacent} in der preamble, wenn Sie microtype mit thailändischen fonts verwenden - Nutzen Sie
\sloppy /\fussy in sections, um das line-breaking von thailändischem Text zu kontrollieren
Practical Workflow
Mein alltäglicher workflow, wenn ich einen section mit Claude schreibe:
- Öffnen einer section Datei — z. B.
sections/d_technology.tex - Beschreiben des Inhalts — ich erkläre Claude in einfacher Sprache, was der section abdeckt und welche diagrams in
figures/ vorhanden sind - Claude entwirft das LaTeX — unter Verwendung der custom commands der class, der korrekten Behandlung von thailändischen font und angemessenen table/figure environments
- Build und Review —
latexmk -r conf/latexmkrc main.tex ausführen undout/main.pdf öffnen - Iterieren (Iterate) — ich füge Kompilierungs-error wieder bei Claude ein, um gezielte Korrekturen vornehmen zu lassen
Die modular strukturierte section ist hier der Schlüssel. Claude muss immer nur eine
Gotchas, die man kennen sollte
-
XeLaTeX ist zwingend erforderlich. Die Ausführung von pdflatex wird sofort bei
\usepackage{fontspec} fehlschlagen. Überprüfen Sie immer die engine in Ihrer build config. - TH Sarabun New muss installiert sein. Auf macOS/Linux sollten Sie es als system font installieren, bevor Sie mit dem building beginnen. CI Umgebungen erfordern oft einen expliziten font Installationsschritt.
-
microtype + Thai benötigt eine config Zeile. Fügen Sie
\microtypecontext{spacing=nonadjacent} hinzu, um Warnungen zu unterdrücken und spacing Konflikte mit thailändischen Zeichen zu vermeiden. -
Das line-breaking von thailändischem Text ist knifflig. Verwenden Sie in sections mit dichter thailändischer Prosa großzügig
\sloppy , um overfull hbox Warnungen zu vermeiden.
Why This Approach Works
Die Kombination der Präzision von LaTeX mit der natürlichen Sprach-interface von Claude beseitigt die Reibung, sich jeden command und jedes environment merken zu müssen.
Ich beschreibe, was ich auf Thai oder Englisch brauche, Claude generiert korrektes LaTeX basierend auf einem klar definierten template, und ich kompiliere sofort zur Überprüfung.
Die
Das template ist Open Source und auf GitHub unter nuboat/template-doc verfügbar.
Klonen Sie es, fügen Sie Ihre eigenen sections hinzu und lassen Sie Claude Ihre
Note: Dieser Blog-Beitrag wurde mit Claude Code geschrieben, wobei das template-doc repository als source material verwendet wurde.
© peerapat.cc