{"id":15636460,"url":"https://github.com/cansik/kotlin-latex-listing","last_synced_at":"2025-07-27T10:17:00.081Z","repository":{"id":47473602,"uuid":"84478708","full_name":"cansik/kotlin-latex-listing","owner":"cansik","description":"A syntax highlighting template for the Kotlin language in LaTeX listings.","archived":false,"fork":false,"pushed_at":"2021-08-30T11:15:17.000Z","size":2086,"stargazers_count":127,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T23:02:18.809Z","etag":null,"topics":["code","highlighting","kotlin","latex","listing","listings","lst","lstdefine","syntax"],"latest_commit_sha":null,"homepage":"","language":"TeX","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cansik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-09T19:08:37.000Z","updated_at":"2025-03-14T10:20:23.000Z","dependencies_parsed_at":"2022-08-29T19:12:14.063Z","dependency_job_id":null,"html_url":"https://github.com/cansik/kotlin-latex-listing","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cansik%2Fkotlin-latex-listing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cansik%2Fkotlin-latex-listing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cansik%2Fkotlin-latex-listing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cansik%2Fkotlin-latex-listing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cansik","download_url":"https://codeload.github.com/cansik/kotlin-latex-listing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248855913,"owners_count":21172665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code","highlighting","kotlin","latex","listing","listings","lst","lstdefine","syntax"],"created_at":"2024-10-03T11:04:11.451Z","updated_at":"2025-04-14T09:41:41.113Z","avatar_url":"https://github.com/cansik.png","language":"TeX","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kotlin for LaTeX Listings [![Build LaTeX](https://github.com/cansik/kotlin-latex-listing/actions/workflows/main.yml/badge.svg)](https://github.com/cansik/kotlin-latex-listing/actions/workflows/main.yml)\nWhen I was writing my bachelor thesis using [Kotlin](https://kotlinlang.org/) and needed to document some code in [LaTeX](https://www.latex-project.org/), I realized that the [lstpackage](https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings) does not support Kotlin syntax highlighting by default. So, I decided to create a language template for it.\n\n![Example](https://github.com/cansik/kotlin-latex-listing/releases/download/example/example.png)\n\nCheck out this example of the default style or [download](https://github.com/cansik/kotlin-latex-listing/releases/download/example/kotlin_example.pdf) the complete document.\n\nFeel free to add more keywords or define new styles!\n\n## How to use it?\nFirst of all, you need to copy the language definition into your LaTeX document:\n\n```latex\n\\usepackage[dvipsnames]{xcolor}\n\\usepackage{listings}\n\n\\lstdefinelanguage{Kotlin}{\n  comment=[l]{//},\n  commentstyle={\\color{gray}\\ttfamily},\n  emph={filter, first, firstOrNull, forEach, lazy, map, mapNotNull, println},\n  emphstyle={\\color{OrangeRed}},\n  identifierstyle=\\color{black},\n  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, receiver, reified, return, return@, sealed, set, setparam, super, suspend, tailrec, this, throw, true, try, typealias, typeof, val, var, vararg, when, where, while},\n  keywordstyle={\\color{NavyBlue}\\bfseries},\n  escapeinside={//(`}{`)},\n  morecomment=[s]{/*}{*/},\n  morestring=[b]\",\n  morestring=[s]{\"\"\"*}{*\"\"\"},\n  ndkeywords={@Composable, @Preview, @Deprecated, @JvmField, @JvmName, @JvmOverloads, @JvmStatic, @JvmSynthetic, Array, Byte, Double, Float, Int, Integer, Iterable, Long, Runnable, Short, String, Any, Unit, Nothing},\n  ndkeywordstyle={\\color{BurntOrange}\\bfseries},\n  sensitive=true,\n  stringstyle={\\color{ForestGreen}\\ttfamily},\n}\n```\n\nThen you need to set the language of your listing to `Kotlin`:\n\n```latex\n\\begin{lstlisting}[caption={Simple code listing.}, label={lst:example1}, language=Kotlin]\n// this is a simple code listing:\nprintln(\"hello kotlin from latex\")\n\\end{lstlisting}\n```\n\nAnd finally, your listing should look like this:  \n![Simple Example](https://github.com/cansik/kotlin-latex-listing/releases/download/example/simple.png)  \n*(The border is not part of the language definition. Check out [example.tex](example/kotlin_example.tex) for this style.)*\n\n### Contributors  \nFeel 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 them to the [Example release](https://github.com/cansik/kotlin-latex-listing/releases/tag/example).\n\nThanks to [@ppizarror](https://github.com/ppizarror), [@ice1000](https://github.com/ice1000), [@etwasanderes2](https://github.com/etwasanderes2/), [@erdodif](https://github.com/erdodif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcansik%2Fkotlin-latex-listing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcansik%2Fkotlin-latex-listing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcansik%2Fkotlin-latex-listing/lists"}