help for mktex Version 3.0 | 05Feb2026

Title

mktex - Convert Microsoft Word (.docx) documents to LaTeX (.tex)
format with full document structure and optional PDF compilation

Important Limitations

mktex is optimized for converting plain text Word documents.
Documents containing complex elements may require additional manual
adjustment or alternative conversion methods:

• Tables: Complex table formatting may not convert correctly

• Mathematical formulas: Use direct pandoc conversion for better results

• Underlined text: Underline formatting (\ul{}) is removed for compatibility

• Complex formatting: Advanced Word features may be simplified

For documents with tables, mathematical formulas, or complex formatting,
we recommend using pandoc directly:

For English documents:

shell pandoc filename.docx -o filename.tex --standalone

For Chinese documents:

shell pandoc filename.docx -o filename.tex --standalone

--pdf-engine=xelatex -V lang=chinese

-V documentclass=ctexart -M mainfont="Microsoft YaHei"

Optional Chinese fonts include: "Microsoft YaHei", "SimHei", "SimSun".

Syntax

mktex using filename.docx [, replace
compile language(str) noctex notoc simple
r c]

mktex , check

where filename is a Microsoft Word document with .docx extension.

options

replace overwrite existing output files

compile compile the generated LaTeX file to PDF

language(str) set document language (e.g., "chinese", "english")

noctex disable automatic ctex package for Chinese documents

notoc disable table of contents generation

simple create minimal LaTeX document without full structure

r short for replace

c short for compile

Description

mktex converts Microsoft Word (.docx) documents to LaTeX (.tex)
documents. It generates complete LaTeX documents with proper preamble,
document structure, and optional table of contents. The command supports
both full document generation and minimal ("simple") output for embedding
in existing documents.

When the compile option is specified, the command compiles the
generated LaTeX file to PDF using available LaTeX engines (pdflatex,
xelatex, lualatex, or latex). If compilation fails, detailed troubleshooting
guidance is provided.

The check option verifies the installation of pandoc and LaTeX,
providing system-specific guidance for setup.

Troubleshooting PDF Compilation

If PDF compilation fails, check the following:

1. Check the log file: Open filename.log in a text editor and look
for error messages starting with '!'.

2. Common issues:

• Complex tables may not convert correctly

• Mathematical formulas may need manual adjustment

• Special characters may cause compilation errors

• Underlined text (\ul{}) is automatically removed

3. Solutions:

• Simplify the Word document (remove complex formatting)

• Use pandoc directly (see Limitations above)

• Manually edit the generated .tex file to fix LaTeX errors

Options

replace (or r) overwrites existing output files.
Without this option, the command exits with an error if the output .tex
file already exists.

compile (or c) compiles the generated LaTeX file to
PDF. The command automatically detects available LaTeX engines and performs
one or two compilations (for proper table of contents when enabled). If
compilation fails, detailed error analysis and solutions are provided.

language(str) specifies the document language. For Chinese
documents, use "chinese", "zh", or "cn". For English documents, use
"english" or "en". Default is "chinese" unless noctex is specified.

noctex disables automatic inclusion of the ctex package for
Chinese documents. Use this option when you want to handle Chinese
typesetting manually or when using alternative LaTeX packages.

notoc disables table of contents generation in full document
mode.

simple creates a minimal LaTeX document containing only the
converted content with basic preamble. This is useful for embedding content
in existing LaTeX documents or when experiencing compilation issues with
the full document structure.

check verifies the installation of pandoc and LaTeX, displays
system information, and provides troubleshooting guidance. This option does
not require a using specification.

Requirements

1. Pandoc: Must be installed from
https://pandoc.org/installing.html.

2. LaTeX Distribution (for PDF compilation): TeX Live, MiKTeX, or
MacTeX.

Examples

Basic conversion with default settings (Chinese document):

. mktex using "report.docx"

Convert, compile to PDF, and overwrite existing files:

. mktex using "thesis.docx", replace compile

. mktex using "thesis.docx", r c (short form)

Create a simple LaTeX document without full structure:

. mktex using "content.docx", simple

Convert an English document without table of contents:

. mktex using "paper.docx", language(english) notoc

Check installation status:

. mktex, check

Output Files

The command can produce the following output files:

1. .tex file: A LaTeX document. In full mode (default), this includes
complete document structure with preamble, packages, title, optional table
of contents, and content. In simple mode, it includes minimal preamble and
content only.

2. .pdf file (with compile option): A compiled PDF document.
When table of contents is enabled, two compilation passes are performed for
proper TOC generation.

3. Log files: Various LaTeX auxiliary files (.aux, .log, .toc, etc.)
are automatically cleaned up after successful compilation. If compilation
fails, the .log file is preserved for error analysis.

Authors

Wu Lianghai, Chen Liwen, Wu Hanyan, Wu Xinzhuo, and
Ma Defang

Anhui University of Technology (AHUT), Ma'anshan, China

Email: agd2010@yeah.net,
2184844526@qq.com

Nanjing University of Aeronautics and Astronautics (NUAA), Nanjing, China

Email: 2325476320@qq.com

University of Bristol (UB), UK

Email: 2957833979@qq.com

Capital Normal University (CNU), Beijing, China

Email: 6346@cnu.edu.cn

Version History

3.0 (05Feb2026): Enhanced error handling and troubleshooting guidance;
added clear warnings about limitations; improved compilation failure
diagnostics; maintained backward compatibility.

2.92 (05Feb2026): Updated program header comments with comprehensive
guidance for handling DOCX files containing tables and mathematical formulas;
improved documentation clarity.

2.9 (31Jan2026): Fixed display command syntax issues; improved Unicode
filename handling; enhanced error messages; fixed variable name
inconsistencies; improved cross-platform compatibility.

2.5 (31Jan2026): Added simple mode for minimal LaTeX output;
improved error handling; enhanced LaTeX engine detection; added noctex
and notoc options; updated installation checker with better
diagnostics; fixed macOS compatibility issues.

2.1 (30Jan2026): Added cross-platform compatibility with macOS support;
users can define pandoc path in profile.do on macOS.

2.0 (28Jan2026): Added complete LaTeX document structure with table of
contents; all options now support single-letter abbreviations; updated
documentation.

1.0 (28Jan2026): Initial release as mktex, basic Chinese character
handling.

Acknowledgments

We extend our sincere gratitude to Christopher F. Baum for his
enthusiastic support and timely scientific guidance. His valuable insights
and constructive feedback have been instrumental in the continuous
improvement and refinement of this program. We deeply appreciate his
dedication to supporting the Stata community.

Type help mktex to display this help file again.

For direct pandoc conversion of complex documents, see examples in
Limitations section.