TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to convert a .tex file into something that is possible to open in MS Word (.doc, .docx, .rtf, ...) by means of the pandoc command line software. A minimum .tex file is attached below. I use the following command in a standard command window when trying to convert :

pandoc -o MyFile.tex MyFile.rtf

This produces the following error message: enter image description here

What does "Invalid UTF-8 stream" mean, and what can I do about it? I am using MikTeX 2.9 and TexWorks.

My latex file MyFile.tex is like this:

% !TeX program    = pdflatex
% !TeX encoding   = ISO-8859-1
% !TeX spellcheck = nb_NO










  \pgfplotsset{plot coordinates/math parser=false}



\hypersetup{pdfauthor = Espen Donali}






my test of pandoc latex to word


enter code here
share|improve this question

You have told your editor that the file is stored as latin1 encoding

% !TeX encoding   = ISO-8859-1

But pandoc thinks it is reading a UTF-8 encoded file so can not decode it. These encodings are the same for ascii letters but differ for anything else.

Pandoc may have an option to tell it the file encoding or if not, you should get your editor to save the file as utf-8.

share|improve this answer
does it mean what? – David Carlisle Feb 12 '13 at 12:33
Thanks :) By changing "ISO-8859-1" to "UTF-8" in my minimum example pandoc functioned ! BUT, when doing the same on my real file, from which the minimum example were made from, I get this error: pandoc: Cannot decode byte '\x72' : Data.Text.Encoding.decodeUtf8: Invalid UTF-8 stream. Is there some mismatch between UTF-8 and any of the packages I have used? – myotis Feb 12 '13 at 12:54
Sorry, I see my last comment was ill posed. I will try to put code, line by line, from my real file into the working example, until the error appears. Then, I might ask you a follow up question : ) – myotis Feb 12 '13 at 13:02
Follow up question: It seems like pandoc needs all latex code to be contained within the sinlge .tex file being processed. But I have numerous occurences of \inpu{} in my masterfile. Are there any functionality in latex letting me construct a new masterfile where all the input files are copied into the masterfile instead of being referred to with the \input{} command ? – myotis Feb 12 '13 at 13:25
Have look at Martin Scharrers answer to this question: tex.stackexchange.com/questions/21838/… – DG' Nov 26 '13 at 14:07

Pandoc uses the UTF-8 character encoding for both input and output. If your local character encoding is not UTF-8, you should pipe input and output through iconv:

iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.