0

I just started using pandoc and I followed every step in this page.
First of all we create a text file named test1.md.txt

# Test!

This is a test of *pandoc*.

- list one
- list two

Convert it to a tex file using the code:

pandoc test1.md.txt -s -o test1.tex  

we get:

\documentclass[]{article}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
\else % if luatex or xelatex
  \ifxetex
    \usepackage{mathspec}
    \usepackage{xltxtra,xunicode}
  \else
    \usepackage{fontspec}
  \fi
  \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
  \newcommand{\euro}{€}
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\ifxetex
  \usepackage[setpagesize=false, % page size defined by xetex
              unicode=false, % unicode breaks when used with xetex
              xetex]{hyperref}
\else
  \usepackage[unicode=true]{hyperref}
\fi
\usepackage[usenames,dvipsnames]{color}
\hypersetup{breaklinks=true,
            bookmarks=true,
            pdfauthor={},
            pdftitle={},
            colorlinks=true,
            citecolor=blue,
            urlcolor=blue,
            linkcolor=magenta,
            pdfborder={0 0 0}}
\urlstyle{same}  % don't use monospace font for urls
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}

\date{}

% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi

\begin{document}

\section{Test!}\label{test}

This is a test of \emph{pandoc}.

\begin{itemize}
\tightlist
\item
  list one
\item
  list two
\end{itemize}

\end{document}  

When we try to convert this final tex file to a docx file, its done appropriately:

pandoc test1.tex -s -o test1.docx  

we get the result as:

enter image description here

but now I have my own tex code named as equation.tex

\documentclass{article}
\usepackage[margin=1in]{geometry}% Just for this example
\usepackage{amsmath}

\begin{document}

\begin{align}
 T_4 &= \langle \underline{k}\,.\,\underline{k}^{*^T} \rangle=
   \left\langle
   \begin{bmatrix}
     |k_1|^2 & k_1k_2^* & k_1k_3^* & k_1k_4^* \\
     k_2k_1^* & |k_2|^2 & k_2k_3^* & k_2k_4^* \\
     k_3k_1^* & k_3k_2^* & |k_3|^2 & k_3k_4^* \\
     k_4k_1^* & k_4k_2^* & k_4k_3^* & |k_4|^2
   \end{bmatrix}
   \right\rangle \\
 &= \frac{1}{2}
   \left[\begin{matrix}
     \langle|S_{XX}+S_{YY}|^2\rangle &
     \langle(S_{XX}+S_{YY})(S_{XX}-S_{YY})^*\rangle &\\
     \langle(S_{XX}-S_{YY})(S_{XX}+S_{YY})^*\rangle &
     \langle|S_{XX}-S_{YY}|^2\rangle & \cdots\cdots\\
     \langle(S_{XY}+S_{YX})(S_{XX}+S_{YY})^*\rangle&
     \langle(S_{XY}+S_{YX})(S_{XX}-S_{YY})^*\rangle & \cdots\cdots\\
     \langle j(S_{XY}-S_{YX})(S_{XX}+S_{YY})^*\rangle &
     \langle j(S_{XY}-S_{YX})(S_{XX}-S_{YY})^*\rangle &
   \end{matrix}\right. \nonumber \\
 & \phantom{{}= \frac{1}{2}}
   \left.\begin{matrix}
     & \langle(S_{XX}+S_{YY})(S_{XY}+S_{YX})^*\rangle
     & \langle -j(S_{XX}+S_{YY})(S_{XY}-S_{YX})^*\rangle\\
     \cdots\cdots& \langle(S_{XX}-S_{YY})(S_{XY}+S_{YX})^*\rangle
     & \langle -j(S_{XX}-S_{YY})(S_{XY}-S_{YX})^*\rangle\\
     \cdots\cdots& \langle|S_{XY}+S_{YX}|^2\rangle
     & \langle-j(S_{XY}+S_{YX})(S_{XY}-S_{YX})^*\rangle\\
     & \langle j(S_{XY}-S_{YX})(S_{XY}+S_{YX})^*\rangle
     & \langle|S_{XY}-S_{YX}|^2\rangle
   \end{matrix}\right]
\end{align}

\end{document}  

And try to convert it to a docx file:

pandoc equation.tex -s -o equation.docx  

I get the result:
enter image description here
This code is fine when used in latex and it does produce the proper pdf file
enter image description here

why doesn't pandoc create the write docx file and it just writes the latex codes in the docx file?

  • 2
    I suspect that your equation is too complex for pandoc to parse. Do you really need this formula in Word, or could you also import it as a figure? – Habi Aug 11 '15 at 13:36
  • @Habi in scientific papers they need editable equations. Will it be too complex for htlatex, too? then we can never convert complex equations from tex to word? Should we start using latex from scratch? – Sepideh Abadpour Aug 11 '15 at 13:46
  • @Habi seems that this equation is too complex for pandoc but not for htlatex. I created an html file by htlatex and then opened the file with word. But you know seems that htlatex just produces an image of the equation not the mathml code. the code that I used is htlatex file.tex html "--interaction=nonstopmode". Seems that there's no way. even htlatex produces an image of the equation not mathml code?!!!! – Sepideh Abadpour Aug 11 '15 at 14:15
  • 1
    Re: "Should we start using latex from scratch?" Yes, indeed that's what I (and probably others here) would suggest for equations that are that complicated. For all the manuscripts I ever submitted I was sending the Journal a PDF, so I did my (less complicated) equations in LaTeX. – Habi Aug 11 '15 at 15:11
  • 1
    You will have to treat one format of your document as source, the other formats (be it PDF, DOC, HTML) as result. Having "editable equations" in all the possible output formats is probably too far-fetched (and even impossible for certain formats) to achieve. – Habi Aug 11 '15 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.