Tex to word using Pandoc

Viewed 2033

I need to convert Latex file (prepared using Elsevier elsarticle class in TexWorks) in to a MS Word document. I searched for possible routes, one of which was to use pandoc. I tried the following with pandoc at the command prompt,

pandoc -s myfile.tex -o document.docx
pandoc --citeproc myfile.tex --bibliography=mybiblio.bib --csl=ieee.csl -o document.docx

Pandoc converted the file into a word document; however some of the information, such as title, keywords, author details etc., were missing. For this missing info, search results said it would be in metadata but I could not locate any metadata file in the elsarticle class.

My question is: how can I locate the missing information and add it in the converted file?

MWE prepared using elsarticle class

\documentclass[preprint,12pt]{elsarticle}

\usepackage{amssymb}


\usepackage{amssymb}
\usepackage{lineno}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{amsmath}
\usepackage{times}
\usepackage{float}
\usepackage{tabularx}   
\usepackage{mathptmx}  
\usepackage{moreverb,url}
\usepackage{lineno} 
\usepackage{natbib} 

\usepackage[colorlinks,bookmarks=false,citecolor=black,urlcolor=black]{hyperref}


\begin{document}

\begin{frontmatter}

\title{tex to docx conversion questions using pandoc}

\author{Author 1}
\ead{abc@domain.com}
\author{Author 2\corref{cor1}}
\ead{xyz@domain.com}
\cortext[cor1]{Corresponding author}

\address{University XYZ}

\begin{abstract}
MWE for pandoc query

\end{abstract}


\begin{keyword}

pandoc; \sep tex to word conversion; \sep elsarticle;

\end{keyword}

\end{frontmatter}

\section{Section 1}
Text goes here....

\begin{equation}
\sigma=\frac{3FL}{2bd^2}
\label{eq:FlexuralStress}
\end{equation}

% May insert an image for testing
%\begin{figure}
%\centering
%\includegraphics[width=6cm]{Figures/anyimage}
%\caption{Inserted image for testing conversion}
%\label{image1}
%\end{figure}



\bibliographystyle{agsm}
\bibliography{Mybiblio.bib} 

\end{document}
2 Answers

Pandoc parses the LaTeX, but is not a full TeX interpreter. By design, it cannot support all packages and document classes. The elsarticle class requires a custom methods to specify metadata, and that custom method is not supported by pandoc.

A solution would be to use a custom parser to extract the necessary information: first, call pandoc with -f latex+raw_tex, which will preserve all unsupported LaTeX commands in pandoc's intermediary document representation, but otherwise work as before. The internal representation can then be modified and post-processed via a filter.

A second approach would be to duplicate the metadata in a separate YAML file:

---
author:
  - Jane Q. Doe
  - John X. Doe
title: excellent paper
---

Then pass this file to pandoc via the --metadata-file parameter.

I've encountered with a similar situation and importing the pandoc generated PDF file to google docs gave good result in terms of headlines, indentations, bullet lists etc.

Related