Kotlin Latex Listing

A syntax highlighting template for the Kotlin language in LaTeX listings.
Alternatives To Kotlin Latex Listing
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Shiki5,41129877 hours ago44August 13, 202234mitTypeScript
A beautiful Syntax Highlighter.
Minted1,582
6 months ago68TeX
minted is a LaTeX package that provides syntax highlighting using the Pygments library. Highlighted source code can be customized using fancyvrb.
Franklin.jl841
19 days ago165mitJulia
(yet another) static site generator. Simple, customisable, fast, maths with KaTeX, code evaluation, optional pre-rendering, in Julia.
Python Latex Highlighting216
4 years ago8bsd-3-clauseTeX
LaTeX style for Python highlighting
Highlight180
5 years ago3gpl-3.0C++
Source code to formatted text converter
Idea Latex139
6 years ago17mitJava
LaTeX plugin for IntelliJ IDEA
Magic Latex Buffer134
2 years ago15Emacs Lisp
Magical syntax highlighting for LaTeX-mode buffers
Jinjahtml Vscode95
4 months ago19mitJavaScript
Syntax highlighting for jinja(2) html templates in vscode
Solidity Latex Highlighting85
6 months ago5mitTeX
Include nice-looking Solidity examples into LaTeX files
Language Latex80
3 years ago38otherCoffeeScript
Syntax highlighting for LaTeX for Atom.
Alternatives To Kotlin Latex Listing
Select To Compare


Alternative Project Comparisons
Readme

Kotlin for LaTeX Listings Build LaTeX

Currently, I am writing my bachelor thesis with Kotlin and need to document some code in LaTeX. The lstpackage does not support kotlin syntax highlighting by default, so I decided to create a language template for it.

Example

Check out this example of the default style or download the whole document.

Feel free to add more keywords or new styles!

How to use it?

First of all you have to copy the language definition into your latex document:

\usepackage[dvipsnames]{xcolor}
\usepackage{listings}

\lstdefinelanguage{Kotlin}{
  comment=[l]{//},
  commentstyle={\color{gray}\ttfamily},
  emph={filter, first, firstOrNull, forEach, lazy, map, mapNotNull, println},
  emphstyle={\color{OrangeRed}},
  identifierstyle=\color{black},
  keywords={!in, !is, abstract, actual, annotation, as, as?, break, by, catch, class, companion, const, constructor, continue, crossinline, data, delegate, do, dynamic, else, enum, expect, external, false, field, file, final, finally, for, fun, get, if, import, in, infix, init, inline, inner, interface, internal, is, lateinit, noinline, null, object, open, operator, out, override, package, param, private, property, protected, public, receiveris, reified, return, [email protected], sealed, set, setparam, super, suspend, tailrec, this, throw, true, try, typealias, typeof, val, var, vararg, when, where, while},
  keywordstyle={\color{NavyBlue}\bfseries},
  morecomment=[s]{/*}{*/},
  morestring=[b]",
  morestring=[s]{"""*}{*"""},
  ndkeywords={@Deprecated, @JvmField, @JvmName, @JvmOverloads, @JvmStatic, @JvmSynthetic, Array, Byte, Double, Float, Int, Integer, Iterable, Long, Runnable, Short, String, Any, Unit, Nothing},
  ndkeywordstyle={\color{BurntOrange}\bfseries},
  sensitive=true,
  stringstyle={\color{ForestGreen}\ttfamily},
}

Then you have to set the language of your listing to Kotlin:

\begin{lstlisting}[caption={Simple code listing.}, label={lst:example1}, language=Kotlin]
// this is a simple code listing:
println("hello kotlin from latex")
\end{lstlisting}

And finally your listing should look like this: Simple Example (The border is not part of the language definition. Check out the example.tex for this style.)

Contributors

Feel free to add new or missing keywords and style enhancements. Just create a pull request. The github actions command automatically builds the example PDF and PNG and uploads it to the Example release.

Thanks to @ppizarror, @ice1000, @etwasanderes2

Popular Latex Projects
Popular Highlighter Projects
Popular Data Formats Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Kotlin
Language
Tex
Latex
Highlighter