一个功能强大的 Markdown 转 Word 文档工具,支持 LaTeX 公式、代码高亮图片生成和论文格式排版。 还在担心实验报告写不完?隆重向您推荐这款cs学生的流水线报告生成器
- Markdown 解析: 支持标题、段落、列表、表格、代码块、图片、引用等
- LaTeX 公式: 完美支持行内公式
$...$和块级公式$$...$$,转换为 Word 原生公式 - 代码高亮图片: 自动从 Carbon.now.sh 生成美观的代码截图
- 图片占位符: 支持
【图1:filename.png - 描述】格式的图片引用 - 论文格式: 自动应用中文论文格式(黑体标题、宋体正文、首行缩进等)
- 自定义样式: 支持通过配置文件自定义标题、正文、表格等样式
- 表格居中: 表格默认居中显示,无多余空格和缩进
- 多种代码主题: 支持 one-light、one-dark、dracula、monokai 等多种主题
直接下载 release中的 md2docx.exe,无需安装 Python 环境。
- 安装 Python 依赖:
pip install -r requirements.txt
pip install latex2word # LaTeX 公式支持- 安装 Chrome 和 ChromeDriver(用于代码图片生成,可选)
# 使用 exe
md2docx.exe input.md
# 使用 Python
python md2docx.py input.mdmd2docx.exe input.md -o output.docxmd2docx.exe input.md -a ./images# 图片模式(默认)- 从 Carbon 生成代码截图
md2docx.exe input.md -c image
# 文本模式 - 直接插入代码文本
md2docx.exe input.md -c textmd2docx.exe input.md --config my_config.jsonmd2docx.exe --gen-config| 参数 | 说明 | 默认值 |
|---|---|---|
input |
输入的 Markdown 文件路径 | 必需 |
-o, --output |
输出的 Word 文档路径 | 与输入同名.docx |
-a, --assets |
图片和资源目录 | Markdown 文件所在目录 |
-c, --code-mode |
代码显示模式 (image/text) | image |
-t, --theme |
Carbon 代码主题 | one-light |
--config |
自定义配置文件路径 | config.json |
--gen-config |
生成默认配置文件 | - |
--list-themes |
列出所有可用主题 | - |
配置文件 config.json 支持自定义以下样式:
{
"styles": {
"title": {
"font_name": "黑体",
"font_name_ascii": "Times New Roman",
"font_size": 16,
"bold": true,
"alignment": "center"
},
"heading1": {
"font_name": "黑体",
"font_size": 14,
"bold": true,
"alignment": "left"
},
"heading2": { ... },
"heading3": { ... },
"body": {
"font_name": "宋体",
"font_size": 10.5,
"alignment": "justify",
"first_line_indent": 2
},
"table": {
"font_name": "宋体",
"font_size": 10.5,
"alignment": "center",
"header_bold": true
}
}
}font_name: 中文字体名称font_name_ascii: 英文字体名称font_size: 字号(磅)bold: 是否加粗alignment: 对齐方式 (left/center/right/justify)space_before: 段前间距(磅)space_after: 段后间距(磅)line_spacing: 行距倍数first_line_indent: 首行缩进字符数
# 一级标题
## 二级标题
### 三级标题行内公式:
这是一个分数 $\frac{a}{b}$ 和平方 $x^2$块级公式:
$$\sum_{i=1}^{n} x_i$$
$$\int_0^\infty e^{-x} dx$$| 列1 | 列2 | 列3 |
|-----|-----|-----|
| A | B | C |```python
def hello():
print("Hello, World!")
### 图片
标准 Markdown 图片:
```markdown

图片占位符(推荐):
【图1:幅频响应.png - IIR滤波器幅频响应曲线】默认样式符合中文论文格式要求:
| 元素 | 字体 | 字号 | 其他 |
|---|---|---|---|
| 标题 | 黑体 | 16pt | 居中、加粗 |
| 一级标题 | 黑体 | 14pt | 加粗 |
| 二级标题 | 黑体 | 12pt | 加粗 |
| 正文 | 宋体 | 10.5pt | 两端对齐、首行缩进2字符 |
| 表格 | 宋体 | 10.5pt | 居中 |
双击 启动GUI.bat 或运行:
python gui.py- python-docx: Word 文档生成
- Pillow: 图片处理
- latex2word: LaTeX 公式转换
- latex2mathml: LaTeX 到 MathML 转换
- mathml2omml: MathML 到 OMML 转换
- lxml: XML 处理
MIT License