Problem
目前 make docx 用 latexpand → sed → pandoc 三步管線將 LaTeX 逐字稿轉為 DOCX,但:
- pandoc 不認識自訂 LaTeX 命令(
\摘要{}、\篇名{}{}、\kw{}、\tc{})
- sed 預處理只能做簡單替換,無法生成帶樣式的 DOCX(字型、顏色、框線)
- 產出的 DOCX 格式粗糙,缺少摘要框、篇名樣式、關鍵詞顏色
Proposed Solution
新增 tex-to-docx-swift converter package,直接解析 LaTeX 源碼並用 OOXMLSwift 生成帶完整樣式的 DOCX。
需要處理的 LaTeX 命令
| 命令 |
PDF 效果 |
DOCX 對應 |
\篇名{行1}{行2} |
思源宋體 Bold 24pt 置中,獨立頁 |
Heading 1 + 置中 + page break |
\摘要{文字} |
灰框白底 ◆ 前綴 14pt |
Quote style + border + ◆ prefix |
\kw{關鍵詞} |
深藍色文字 |
Bold + blue color |
\tc{時間碼} |
灰色括號 |
Gray colored run |
\section{} |
白字深色底條 |
Heading 2 |
\subsection{} |
深棕色粗體 |
Heading 3 |
\subsubsection{} |
深藍色 + 【】 |
Heading 4 |
Architecture
- Package:
packages/tex-to-docx-swift/
- Converter:
TeXToDOCXConverter conforming to DocumentConverter
- CLI:
macdoc tex to-docx input.tex -o output.docx
- Dependencies:
common-converter-swift, ooxml-swift
- Uses
latexpand (or built-in \input expansion) to flatten before parsing
Related
Problem
目前
make docx用latexpand → sed → pandoc三步管線將 LaTeX 逐字稿轉為 DOCX,但:\摘要{}、\篇名{}{}、\kw{}、\tc{})Proposed Solution
新增
tex-to-docx-swiftconverter package,直接解析 LaTeX 源碼並用 OOXMLSwift 生成帶完整樣式的 DOCX。需要處理的 LaTeX 命令
\篇名{行1}{行2}\摘要{文字}\kw{關鍵詞}\tc{時間碼}\section{}\subsection{}\subsubsection{}Architecture
packages/tex-to-docx-swift/TeXToDOCXConverterconforming toDocumentConvertermacdoc tex to-docx input.tex -o output.docxcommon-converter-swift,ooxml-swiftlatexpand(or built-in\inputexpansion) to flatten before parsingRelated
00_common/commands.tex