Kotlin language template for Latex.
it base on Kotlin for LaTeX Listings
Theme referred to Xcode
Download files named Kotlin.tex and package.tex on TexConfig
Or copy that code on Kotlin.tex to your .tex file
if you copy code or just use Kotlin.tex, you HAVE to
Delete \input{TexConfig/package}
Add \usepackage[dvipsnames]{xcolor} \usepackage{listings} and \usepackage{fontspec}
% delete this on Kotlin.tex
\input{TexConfig/package}
% add this on Kotlin.tex
\usepackage[dvipsnames]{xcolor}
\usepackage{listings}
\usepackage{fontspec}
Import file Kotlin.tex, suggest you import on main.tex, just like this
\documentclass[a4paper, 11pt]{report}
\input{TexConfig/Kotlin} % check the location where Kotlin.tex is
\title{My First Document}
One way to use:
\begin{lstlisting}[caption={print something}, label={lst:kt}, language=Kotlin]
// this is a simple code of kotlin:
println("hello kotlin from latex")
\end{lstlisting}
Then listing should look like this:
Another way to use:
\lstinputlisting[label={lst:kt3}, language=Kotlin]{Kotlin/Test.kt}
It is recommended that you split your code into different files, or use the first way
% use \lstdefinelanguage define language
\lstdefinelanguage{languageName}{
style = styleName,
}
% use \lstdefinestyle define language style
\lstdefinestyle{styleName}{
basicstyle=\normalfont\ttfamily\normalsize,
more style setting...
}
Thank you for your contributions @cansik