Latex 使用Pandoc将Tex转换为word

Latex 使用Pandoc将Tex转换为word,latex,pandoc,Latex,Pandoc,我需要将Latex文件(使用TexWorks中的Elsevier elsarticle类编写)转换为MS Word文档。我搜索了可能的路线,其中之一就是使用pandoc。我在命令提示符下使用pandoc尝试了以下操作 pandoc -s myfile.tex -o document.docx Pandoc将文件转换为word文档;然而,一些信息,如标题、关键字、作者详细信息等,却丢失了。对于这个丢失的信息,搜索结果说它将在元数据中,但我在elsarticle类中找不到任何元数据文件 我的问题是

我需要将Latex文件(使用TexWorks中的Elsevier elsarticle类编写)转换为MS Word文档。我搜索了可能的路线,其中之一就是使用
pandoc
。我在命令提示符下使用pandoc尝试了以下操作

pandoc -s myfile.tex -o document.docx
Pandoc将文件转换为word文档;然而,一些信息,如标题、关键字、作者详细信息等,却丢失了。对于这个丢失的信息,搜索结果说它将在元数据中,但我在elsarticle类中找不到任何元数据文件

我的问题是:如何找到丢失的信息并将其添加到转换后的文件中

MWE使用elsarticle类编写

\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}

Pandoc解析LaTeX,但不是完整的TeX解释器。根据设计,它不能支持所有包和文档类。
elsarticle
类需要一个自定义方法来指定元数据,而pandoc不支持该自定义方法

一种解决方案是使用自定义解析器提取必要的信息:首先,使用
-f latex+raw_tex
调用pandoc,这将在pandoc的中间文档表示中保留所有不受支持的latex命令,但在其他方面与以前一样工作。然后,可以通过一个应用程序修改和后处理内部表示

第二种方法是在单独的YAML文件中复制元数据:

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

然后通过
--metadata file
参数将此文件传递给pandoc。

您使用的是最新的pandoc版本吗?您可以使用
-s-t native
查看它是否被读取。。。然后你可以用a来做点什么…这真的是两个问题合一。我建议将此问题限制在pandoc上,并将您的htlatex问题重新发布到上。@mb21是的,我使用的是最新版本的pandoc。我是否可以找到元数据文件(如果它是在将Latex编译为pdf文件时在某处创建的),然后在命令提示符下使用pandoc直接调用它?Thanks@tarleb我对问题进行了编辑,将其限制为仅限于pandoc。ThanksI输入了
pandoc-s-t native
,然后在新行
Ctrl+z
enter中点击enter,并显示以下消息,
pandoc(Meta{emota=fromList[]})[
@mb21
---
author:
  - Jane Q. Doe
  - John X. Doe
title: excellent paper
---