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
Comments
Very interesting, I did not now that LaTex maybe used in such a way. How it is used Syntax Highlighting, maybe I can help?
How Pygments related? Some time ago I started to do Syntax highlightings to Pygments but did not finished it, yet. But I have textmate grammar, which can be used in many places.
Mint LaTex package uses Pygments as an actual colorizer.
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!
Thanks for your answer!
I will definitely look into it.
I've seen this post to. It would also be an idea yes.
I'd have to generate html out of my code then transform it to LaTeX and use it in my file.
Converting to html and parsing html has room for errors or missinterpretation egain.
And of course I'd have try to make my own LaTeX package or compile everything by hand everytime which is also kind of an overkill.
Better unhighlighted code than a picture.
Look in the direction of the DocBook that is used in the embedded InterSystems documentation. There is support for highlighting for many languages: Caché Basic, Caché ObjectScript, Caché Class Definition Syntax, etc.
Very long ago (2012), I wrote an article on this topic, but it is in Russian (machine translation).
This post about the %SyntaxColor class might be useful as a starting point:
https://community.intersystems.com/post/syntax-highlighting-objectscript
It wouldn't integrate seamlessly with the LaTeX toolchain, but you could probably transform its output into something usable.
At the moment I am working with %Syntax Color and a self built pipeline.
If I have the time I will try to finish syntax highlighting in pygments and post it on here if it is finished.
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.