1

I have a large LaTeX file generated with dblatex. When I replace lstlisting environment with minted it fails to process it. XeLaTeX produces following errror:

! Missing \endcsname inserted.
<to be read again> 
               \global 
l.2 ...de \PYGdefaultZlt{}stdio.h\PYGdefaultZgt{}}

Has anyone tried using dblatex with minted? https://github.com/sciactive/2be-extras/blob/master/documentation/doc-pdf.sh git repository has integration of dblatex with minted but even that does not work.

A sample xml can be

<article xmlns="http://docbook.org/ns/docbook" 
          xmlns:xl="http://www.w3.org/1999/xlink" version="5.0">
      <title>Test article</title>

     <para>
     <application xl:href="http://www.gnu.org/software/emacs/">Emacs</application> 
        is my favourite text editor.</para>
     ...
    <programlisting language="c">#include &lt;stdio.h&gt;</programlisting>
    </article>

The TeX file can be generated via command dblatex -bxetex -p dblatex.xsl -t tex test.xml.

Then minted can be included and processed with XeLaTeX for the error.

  • Welcome to TeX.SX! Do you think you can give an MWE of what you are trying to do and what causes the error? It would also be good if you could explain your work flow if it involves more than just running XeLaTeX on your file. – moewe Oct 20 '15 at 12:57
  • I have edited the question to contain github repository. – Bugbugbuggerbuggered Oct 20 '15 at 13:18
  • Please try giving us a minimal example that we can try out. It is also preferred to add paste the code directly to your question, so we can simply copy it to our machines and have a go. – moewe Oct 20 '15 at 13:21
  • I have created an MWE. – Bugbugbuggerbuggered Oct 20 '15 at 13:33
2

There are a lot of things that have to be fixed. [Related GitHub discussion]

fancybox and fancyvrb conflict. For things to work correctly, fancyvrb must be loaded last. Both of these packages are loaded by the db2latex package, so neither of them are needed in your output.tex file.

The package db2latex attempts to load the two packages in the correct order, but overlooks the fact that it has already loaded fancyvrb in the subpackage dbk_verbatim, which loads listings which loads fancyvrb. Even if that wasn't the case, dbk_misc would load fancyvrb explicitly. So db2latex ultimately ends up loading fancybox last, which is wrong. You would need to comment out the \usepackage{fancybox} in db2latex.sty, or move it to before \usepackage{dbk_verbatim}.

If fancybox is loaded anywhere by db2latex, then minted must be loaded after db2latex, because minted will load fancyvrb, and thus fancyvrb wouldn't be loaded last. If fancybox isn't ever loaded, then minted can be loaded anywhere.

Once that is done, there is still a problem because dbk_misc.sty uses \lstset{fancyvrb=true}, which overwrites the fancyvrb internals with listings versions. You would need to comment that out, or have \lstset{fancyvrb=false} in your output document somewhere after loading db2latex.

  • Thanks a bunch. I was loading minted last but I do not know TeX much. I barely survive. I just put one line \lstset{fancyvrb=false} before minted and that did the trick. – Bugbugbuggerbuggered Oct 20 '15 at 18:27
  • Cannot vote up answer. No reputation. :( – Bugbugbuggerbuggered Oct 20 '15 at 18:28

Your Answer

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

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