Skip to content

NullTar/Kotlin-for-LaTeX-Listings-Plus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kotlin for LaTeX Listings Plus

简体中文

Kotlin language template for Latex.

it base on Kotlin for LaTeX Listings

Theme referred to Xcode

image

How to use it?

First.

Download files named Kotlin.tex and package.tex on TexConfig

Or copy that code on Kotlin.tex to your .tex file

image

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}
Second.

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}
Third.

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: 截屏2024-05-09 17.46.36

Another way to use:

\lstinputlisting[label={lst:kt3}, language=Kotlin]{Kotlin/Test.kt}

截屏2024-05-09 17.46.36

It is recommended that you split your code into different files, or use the first way

Define additional topics

% use \lstdefinelanguage define language
\lstdefinelanguage{languageName}{
    style = styleName,
}
% use \lstdefinestyle define language style
\lstdefinestyle{styleName}{
		basicstyle=\normalfont\ttfamily\normalsize,
		more style setting...
}

Thanks

Thank you for your contributions @cansik

About

Kotlin language template for Latex.

Resources

Stars

Watchers

Forks

Packages

No packages published