Md Abdus Samad
  • About
    • News
    • Contact
  • Publications
  • Top Global Scholarships
  • University Information
  • LaTeX
  • Miscellaneous
    • List of Publishers
    • Journal Templates
    • Verifying Journal Indexing
    • Reference, Image Quality, and Detexify
    • Author Services by Major Publishers
    • Document Conversion and Figure Tools
    • Manuscript Anonymization
    • Switching Elsevier LaTeX Templates
    • DOCX to LaTeX Convert
    • LaTeX Reference and Label Management
    • Latex Reference Converter
    • Sequential Section Labels
    • Open Access Journals having Discount Policy
    • Overleaf git sync issues
    • Latexdiff Configuration Guide
    • Open source tools
    • Windows shortcuts & commands
    • Mathpix PDF to Word

On this page

  • Step 1: Prepare Your DOCX File
  • Step 2: Extract and Convert Images
    • Extract Images Using Pandoc
    • Convert Image Formats
    • Manual Image Extraction
  • Step 3: Install Required Software
  • Step 4: Obtain elsarticle Class Template
  • Step 5: Convert DOCX to LaTeX
  • Step 6: Compile the LaTeX Document
  • Summary

DOCX to LaTeX Conversion Guide

A Comprehensive Guide for Converting Microsoft Word Documents to LaTeX Format Using the elsarticle Document Class

Author

Dr. Md Abdus Samad

Published

May 30, 2025

NoteOverview

This guide provides a systematic approach to converting DOCX files to LaTeX format, specifically tailored for academic papers using the elsarticle document class. The process involves proper preparation, image handling, and automated conversion using Pandoc.


Step 1: Prepare Your DOCX File

Proper document preparation is crucial for successful conversion. Ensure your Word document follows standard formatting conventions.

  • Format headings properly using built-in styles (Heading 1, Heading 2, etc.)
  • Ensure images and tables are correctly inserted and positioned
  • Avoid TIFF images when possible, prefer PNG or JPG formats
  • Standardize author names, affiliations, and email addresses
  • Use consistent citation and reference formatting

Step 2: Extract and Convert Images

Images require special handling during the conversion process. Use these methods to extract and optimize your images.

Extract Images Using Pandoc

Pandoc can automatically extract all images from your DOCX file while preserving references:

pandoc myfile.docx --extract-media=./media -o temp.tex

Convert Image Formats

Convert TIFF images to web-friendly formats using ImageMagick:

magick convert input.tiff -resize 50% output.png

Batch convert multiple images:

cd media
magick mogrify -resize 50% -format png *.tiff
magick mogrify -resize 50% -format jpg *.jpg

Manual Image Extraction

Alternative method for extracting images manually:

  • Rename your .docx file to .zip
  • Extract the ZIP file using any archive utility
  • Navigate to the word/media/ folder
  • Copy all images to your working media directory
NoteNote

Using Pandoc’s --extract-media option automatically preserves image references and file paths in the generated LaTeX code.


Step 3: Install Required Software

Ensure you have the necessary tools installed on your system.

  • Install Pandoc from the official website: pandoc.org/installing.html
  • Install a LaTeX distribution:
    • TeX Live (Linux/Windows)
    • MikTeX (Windows)
    • MacTeX (macOS)
  • Optional: Install ImageMagick for image processing

Step 4: Obtain elsarticle Class Template

The elsarticle document class is required for Elsevier journal submissions.

  • Download the official template from Elsevier LaTeX Instructions
  • Extract the template files to your working directory
  • Ensure elsarticle.cls is present in your project folder
WarningImportant

Keep the elsarticle class file in the same directory as your LaTeX document to avoid compilation errors.


Step 5: Convert DOCX to LaTeX

Use Pandoc to perform the actual conversion from DOCX to LaTeX format.

pandoc myfile.docx -s -o output.tex --from docx --to latex

For more control over the output, you can specify additional options:

pandoc myfile.docx -s -o output.tex --from docx --to latex --bibliography=references.bib --citeproc
TipTip

The generated LaTeX file may require minor manual adjustments for figures, tables, and references to ensure proper formatting.


Step 6: Compile the LaTeX Document

Compile your converted LaTeX document to generate the final PDF.

  • Ensure all images are properly placed in the media folder
  • Verify that the elsarticle class file is in the correct location
  • Run the LaTeX compiler
pdflatex output.tex

For better Unicode support and modern fonts, use XeLaTeX:

xelatex output.tex
NoteMultiple Compilations

You may need to run the compiler multiple times to resolve cross-references and generate the bibliography correctly.


Summary

The complete workflow for DOCX to LaTeX conversion:

  1. Prepare your DOCX file with proper formatting
  2. Extract images using Pandoc or manual methods
  3. Install Pandoc and a LaTeX distribution
  4. Obtain the elsarticle class template
  5. Convert using Pandoc command
  6. Compile with pdflatex or xelatex
TipPro Tip

For complex documents, consider using Overleaf which provides an online LaTeX editor with the elsarticle template pre-installed.

 

© 2025 Dr. Md Abdus Samad. All rights reserved.