Question
· Apr 2, 2019

Cache Object Script LaTeX highlighting

At the moment I am trying to write a documentation file for a project and intend to use LaTeX for it.
Has anyone already had experience with this? I haven't found syntax highlighting with the LaTeX packages I know yet.
I found a request on Pygment but it was from 2016 and there was no reply on it since then.

Does anyone know a simple way for syntax highlighting COS in LaTeX?
Thanks for your input!
 

Martin

Discussion (10)1
Log in or sign up to continue

I would like to generate a documentation PDF via LaTeX.
In LaTeX you can define code listings where you copy the source code into and LaTeX styles them accordingly on compilation.
The only other way I could think of was screenshotting my code and then integrate those pictures into my LaTeX file. 
Changes in code or copying the code out of the document wouldn't be that easy anymore then though. 

https://de.overleaf.com/learn/latex/Code_Highlighting_with_minted

The minted package used in this example uses Pygments to generate highlighted code for LaTeX.
I only knew the minted and lstlisting packages for LaTeX but I will look for a package that can maybe interpret textmate grammar.
Thanks for your fast reply!

Hi Martin Webber,
You can easily highlight texts in latex using different packages. Especially for highlighting texts, you can either use "soul" or "xcolor". Once you have used these packages, you can use the "\hl{}" command to highlight the texts that you wish. Kindly, note that in the command "\hl", both "h" and "l" are small letters. For example, you can use a code like this: \documentclass{article}
\usepackage{color,soul}
\begin{document}
\hl{My Document}\\
\textbf{Lorem Ipsum} dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\\
\end{document} If you are facing difficulties in compiling documents in LaTeX, I would suggest you to use this guide (https://typeset.io/resources/learn-latex-beginners-step-by-step-guide/) while typesetting your documents. Or else, just drop your question here and I will be happy to offer any help that I could.