Compatibility with code blocks linting packages like `listings` or `minted`

I am trying to display code blocks with some formatting feature, possibly syntax highlighting, from a Latex block in a Google Doc. An example of output I would like to achieve is:

image

I have tried two packages.

1) listings package

Inserting the following Latex block:

\usepackage{listings}
\begin{lstlisting}[language=html]
<html>
    <head>
        <title>Hello</title>
    </head>
    <body>Hello</body>
</html>
\end{lstlisting}

returns:

2) minted package

This would be my preferred choice, as it also support syntax colouring, unlike listings. However, inserting the following Latex block:

\usepackage{minted} 
\begin{minted}{html} 
<!DOCTYPE html> 
<html> 
  <head> 
    <title>Hello</title> 
  </head> 
  <body>Hello</body> 
</html> 
\end{minted}

Returns the same incorrect output as the listings package block:

Is any of those two packages supported, am I doing something wrong?

The listing package should be working, make sure that all the LaTeX code statements that are usually present in the preamble of the LaTeX document e.g. \usepackage{} are included in a separate block at the very top of the first page in Google Docs. See the example below.

1 Like

Thank you. I tried that, and in part it works, but for me the output does not come out as nice as I was hoping, for some reason. Something messes up the spacing. Any hint?

image