convert_to_latex
Convert Markdown to LaTeX source code for research papers and PDF compilation. Transforms sections, formatting, lists, tables, and math expressions into valid .tex syntax. Export to file or return as string for pdflatex or xelatex workflows.
Instructions
Convert Markdown to LaTeX source code. Produces a LaTeX document fragment with \section, \textbf, \textit, \begin{itemize}/\begin{enumerate} list environments, verbatim code blocks, and table environments. KaTeX math expressions in the Markdown are passed through as native LaTeX math. Side effects: when output_path is provided, writes the .tex file to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns the LaTeX source as a string. Returns: LaTeX source string (if no output_path), or JSON { success, file_path, file_size_bytes, format } (if output_path set). Use this when you need to embed content in a LaTeX workflow or compile to PDF via pdflatex/xelatex externally. For direct PDF output without a LaTeX toolchain, use convert_to_pdf instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| markdown | Yes | The raw Markdown source text to convert. Supports GitHub-Flavored Markdown (tables, task lists, strikethrough) and KaTeX math expressions. Pass the full document content as a string, not a file path. | |
| output_path | No | Optional. Absolute or relative file path (e.g. './output.txt') where the result will be saved. Parent directories are created automatically. If omitted, the converted text content is returned directly in the response as a string. If provided, the file is written to disk and a JSON summary with { success, file_path, file_size_bytes, format } is returned instead. |