Export file contaning code blocks to LaTeX

Code blocks are not exported correctly. The file:

The exported LaTeX:

which does not compile. It looks \end{alltt} cause the problem, but I don’t know why. I didn’t find detailed guide for the alltt package.

Nevertheless, the minted package should be better (it supports syntax highlighting). However, it seems it can’t be included in a newenvironment.

I guess we can update or customize the export mechanism to use minted directly and not using newenvironment?

1 Like

Could you please post here the code for the TeXmacs file (copy from a text editor the whole .tm file).


The package alltt is described here: https://ctan.org/pkg/alltt?lang=en



    #include \<less\>iostream\<gtr\>

    int main () {

    \ \ \ \ std::cout \<less\>\<less\> "Hello World!" \<less\>\<less\>



I tested it, my exported file is


%%%%%%%%%% Start TeXmacs macros
\newenvironment{tmcode}[1][]{\begin{alltt} }{\end{alltt}}
%%%%%%%%%% End TeXmacs macros


\#include <iostream>
int main () \{
    std::cout << "Hello World!" << std::endl;


which seems the same as yours, and it did compile.

1 Like

Thanks. It compiles now, not sure what caused the problem before. Switching to minted still not work, but that’s a latex problem. I can manually change those environment, but I also need to remove \ from \#, \{ and \}.