Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conversion error in pandoc referring to line outside of source file

Tags:

latex

pandoc

I'm trying to convert a latex document to docx (damn you journals that do not accept latex or pdf submissions), but get an error referring to a line outside the range of the latex source file (the file is 385 lines). I have checked the only instances of \\ (within a table) and these seem unproblematic. The error also remains if the table is removed. The latex source compiles to pdf in MiKTeX.

The error occurs if I try to convert to other formats as well, so it is not an issue specific to docx conversion. It is hard to make a reproducible example since I dont know what part of the code that is causing the problem (since it is referring to a line number outside of the inputfile). Is the error message referring to the pandoc source?

Command:

 pandoc -f latex article.tex -o article.docx

Error message:

pandoc.exe:
Error:
"source" (line 407, column 1):
unexpected "\\"
expecting white space, "%", new-line, "begin", letter, "*", "[", "}", "egroup",  
"endgroup", "{", "bgroup", "begingroup", "-", "``", "`", "'", "~", "$$", "$", "^", "_",
"^^", "]", "#", "&", "\\" or "
end"

Any ideas on how to trouble shoot?

Don't know if this more suitable for Stackoverflow or http://tex.stackexchange.com, but there are more search hits for pandoc over here.

Edit:

I have now found out that the conversion works if the input file is moved to ./temp/input.tex, and I'm really confused. The associated files (.eps, .bib) was moved along with it, and files in both folders have been renamed so that no old temporary files are influencing the tex conversion. The original folder does not have any weird characters or white space. I'm even more confused and annoyed. However, at least I can get the converted file.

like image 926
fileunderwater Avatar asked Jun 20 '13 13:06

fileunderwater


1 Answers

For your question about how to troubleshoot, try putting an \end{document} in places in your document. If your issue is an element that can reach its closure in latex, but fails to close in pandoc, you might be able to locate the unclosed element by truncating the document at other places.

The following doesn't give exactly your error, but I was able to binary-search and pare down a much longer failing document to this bug using this \end{document} idea.

\documentclass{article}
\usepackage{alltt} 
\begin{document} 
\begin{alltt} 
main <- {sprintf("x = %5.3f",3.1415926)} 
\end{alltt} 
\end{document}
like image 61
Dave X Avatar answered Oct 20 '22 05:10

Dave X