As I am new to Latex and this kind of typing in general, I find myself in need of some basic guidelines when it comes to how to make things look good in text. I have a document that looks good when typeset into a .pdf, but when I compile it to .html using htlatex
the text loses its color, making it more difficult to distinguish from the surrounding text.
How can I write bash text so that it looks good when compiled into an html-file? Is there a commonly used method that makes bash look good?
Right now I use an environment every time:
\newenvironment{vtim}
{\color{magenta}
\begin{tt}
\fontsize{11pt}{11pt}\selectfont}
{\end{tt}}
And then, when I want bash in text:
\begin{vtim}
\$ Text text text text text
\end{vtim}
Best Answer
For
pdf
output you can use theminted
package. This produces a nicely formatted and coloured PDF file for you.As described in the
minted
package documentation, you have to installPygments
and run (pdf)latex with the-shell-escape
option. To use this approach to producehtml
you also need to pass the-shell-scape
option tohtlatex
. You can do this usingNote that the three double quotes
"" "" ""
are necessary as the-shell-escape
has to be the fifth option tohtlatex
.Running
htlatex
on my MWE below gives the following html output:I was going to put up two images but, as far as I can tell, the PDF and HTML output are identical.
Finally, here is my MWE:
Btw, I just learnt that
minted
also has a very useful command:You can use this to typeset your source code without physically including it in your tex document.