Metadata-Version: 2.4
Name: tex2ieeedocx
Version: 0.1.0
Summary: Convert IEEEtran LaTeX papers into IEEE-formatted Word documents
Author-email: dikaizm <dikamaah@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/dikaizm/tex2ieeedocx
Project-URL: Repository, https://github.com/dikaizm/tex2ieeedocx
Project-URL: Issues, https://github.com/dikaizm/tex2ieeedocx/issues
Keywords: latex,ieee,docx,word,academic,conference-paper
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Text Processing :: Markup :: LaTeX
Classifier: Topic :: Office/Business :: Office Suites
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: python-docx>=1.1
Dynamic: license-file

# tex2ieeedocx

Convert an IEEEtran LaTeX paper into a Word document that follows the IEEE
"conference-template-a4" Word template — A4 page, two columns, Times New
Roman, Roman-numeral section headings, `TABLE I` captions above tables,
`Fig. 1.` captions below figures, and an 8 pt hanging-indent reference list.

Written for camera-ready submissions (EDAS and similar) that ask for a Word
version alongside the PDF. Geometry in `style.py` (page size, margins, column
gap) is copied verbatim from that template's own `word/document.xml`
(`w:pgSz`/`w:pgMar`/`w:cols`), not estimated — IEEE also publishes a
US-Letter variant with different margins; swap those constants if that's
the target instead.

## Install

```bash
python -m venv .venv && .venv/bin/pip install -e tools/tex2ieeedocx
```

Only dependency: `python-docx`.

## Use

```bash
tex2ieeedocx paper.tex -o paper.docx
# or
python -m tex2ieeedocx paper.tex -o paper.docx
```

```python
from tex2ieeedocx import convert
warnings = convert("paper.tex", "paper.docx")
```

Options: `--aux` / `--bbl` to point at cross-reference and bibliography files
explicitly (by default `paper.aux` and `paper.bbl` next to the `.tex`),
`--strict-images` to fail instead of warn on a missing figure, `-q` to silence
warnings.

Run the paper through `latexmk` first. The converter reads `.aux` for the
numbers LaTeX assigned to every `\label`, and `.bbl` for the formatted
bibliography, so numbering matches the PDF exactly instead of being guessed.

## What it handles

| Area | Support |
|---|---|
| Structure | `\section`, `\subsection`, `\subsubsection` with IEEE numbering (`I.`, `A.`, `1)`) |
| Front matter | `\title`, `\author` (IEEEtran `\IEEEauthorblockN/A`, `\and`, `\linebreakand`, and custom `\authcol{name}{affiliation}`), `abstract`, `IEEEkeywords` |
| Inline | `\textbf`, `\textit`, `\texttt`, `\textsc`, `\underline`, `\textsuperscript`, font switches (`\bfseries`, `\itshape`), quotes, dashes, `~`, `\ldots`, escapes |
| Math | `$...$` mapped to Unicode with real super/subscript runs (Greek, relations, `\times`, `\frac`, `\sqrt`) |
| References | `\cite` resolved to bracketed numbers from `.bbl`, consecutive runs compressed (`[5]-[11]`); `\ref` resolved from `.aux` |
| Floats | `figure`, `figure*`, `table`, `table*`; starred floats get their own single-column section so they span the page like in LaTeX |
| Tables | `tabular`, `tabular*`, `tabularx`, column specs incl. `p/m/b` and `>{\centering}` (their explicit widths are read and applied as ratio-split column widths, e.g. `p{4cm}`/`p{4.6cm}` → 4:4.6), `\multicolumn`, `\multirow` (rendered as a real OOXML vertical cell merge, not stacked blanks), `\hline`, `\cline`, several caption+tabular pairs in one `table` environment, images inside cells, trailing `\footnotesize` notes |
| Lists | `enumerate`, `itemize`, `quote` |
| Macros | user `\newcommand` definitions from the preamble are expanded, including ones with arguments |
| Images | extension resolution (`figures/x` → `figures/x.png`), widths from `width=0.5\columnwidth` |

Every table and author-row table also gets its OOXML `tblGrid` column widths
set explicitly (`table.columns[i].width`, not just per-cell `width`) — without
that, Word/LibreOffice fall back to their own default column widths under a
"fixed" layout and content overflows past the table border.

## Known gaps

- Word cannot embed PDF/EPS figures; those are replaced by a placeholder and
  reported as a warning. Convert them to PNG first.
- Display math (`equation`, `align`) is rendered as one styled line, not as an
  OMML equation object — `\frac{a}{b}` becomes `a/b` rather than a stacked
  fraction. An `equation` whose body is really text set to look like math
  (wrapped in `\texttt`/`\textit`/`\textbf`, e.g. `y = \texttt{[ClassName]
  description}`) is detected and typeset as text instead of run through the
  math translator, which cannot parse those commands.
- Float placement is Word's: floats land where they appear in the source
  instead of being pushed to the top or bottom of a page.
- No support for `\newtheorem` environments, `algorithm2e`, or TikZ pictures.

## Legacy .doc

`tex2ieeedocx` only writes `.docx` (OOXML). For the older binary `.doc`
format some venues still ask for, convert with LibreOffice headless:

```bash
soffice --headless --convert-to doc --outdir out/ paper.docx
```

On macOS, `soffice` is inside the app bundle if it's not on `PATH`:
`/Applications/LibreOffice.app/Contents/MacOS/soffice`.

## Tests

```bash
python tests/test_convert.py
```

Covers the tokenizer, inline parser, macro expansion, math translation, the
tabular grid model, and a full source-to-docx round trip that reopens the file
and asserts the section/column layout.
