Normie sets Kate for LaTeX
January 27, 2024;
Not to sound like a hipster, but I have been playing with FreeBSD. On metal, I have Thinkpad X260 for such experiments - this laptop is very compatible, and here is a nice blog post which covers few tweaks to make everything work.
I decided to try KDE with it, for the first time since 2012 - actually, really enjoyed its development, would think about switching from GNOME. Eventually, I thought it would be fun to write down experience with setting Kate. My focus was on making life easier with LaTeX, as hardly I do anything complex with other languages or tools.
Beforehand, alternatives. VS Code is probably the new Emacs indeed, and with extensions it makes an excellent LaTeX editor (and with seamless WSL integration
- the best editor for Windows). But VS Code is slow - runs fantastic on my 5700X desktop, but very much not that fantastic on older laptops. Dedicated LaTeX editors are good - I wrote thesis with Texmaker, some papers on Overleaf (cloud editor), and there is of course another KDE project, Kile - which is Kate, fused with Okular and pre-configured with everything the joy of TeX requires. But nowadays, I prefer universal editors. And Kate shines here - somehow I appreciate how flexible without external plugins Kate is.
Few thoughts
Kate runs Konsole, the default KDE terminal, for built-in terminal emulation. Convenient and one less thing to configure. Unfortunately, there is no support of either tabs, splits or multiple instances.
A funny note, the default color scheme I got, Breeze Light (inherited from the global theme), is plain perfect. I am not that interested in ricing, and happy if defaults make sense.
Minor changes first
Vim mode is enabled through “Configure” - “Editing” - “Default input mode”, but with several quirks. A mix of default shortcuts and whatever the NORMAL mode offers is confusing and renders the VISUAL BLOCK mode absent (ctrl-v). On the same “Editing” page, “VI Input mode” tab, there is an option to override Kate’s shortcuts. Also, unless vim mode is enabled, relative line numbering is unavailable.
Kate does not read vim config from local .vimrc
or init.vim
. One could import custom key
mappings from the dotfile, but no more.
Word wrapping requires little tinkering. Hard line breaks are off by default. I like to keep both hard break and soft wrap (“Appearance” - “Dynamic word wrap”). Of course, whenever dynamically wrapped lines are edited, breaks are introduced.
Spellchecking
I am sure things work out of the box if Kate comes with KDE spins, but nothing was in place with FreeBSD install. Kate, as most KDE applications, uses Sonnet - a library that links it to spellchecking applications of choice. I went with hunspell, merely to keep it consistent with Firefox (which I sometimes use) or LibreOffice (which I never use). Dictionaries are installed separately (e.g., en-hunspell). It was enough to set spellchecking in system settings then.
Actual LaTeX
By default, Kate does syntax highlighting, that is it. There would be no autocompletion. Frankly
speaking, not a catastrophe - I used to typeset without it. Yet, closing environments manually can
be annoying and opening curly brackets with the Swedish layout is superduper annoying.
Editor-agnostic approach is to hook LSP server for linting, autocompletion and other tooling. Kate’s LSP client is pre-configured to pick TexLab up, I had to merely install it. Albeit, TexLab performance differs across versions substantially! The current version available in ports collection is 4.2, rather dated and a little slow. I checked on Fedora (the program is not in repos, binaries are here), contemporary release is way faster.
There is no preview in a standard sense, and probably for good - unless incremental compilation is
implemented, continuous recompiling with big documents becomes tedious. If critical, workarounds
exist - to exemplify, latexmk
and TexLab are
configurable to provide preview
functionality. With linting in place, problems are spotted early - so I don’t have to recompile
the document frequently. To compile from Kate’s interface, Build
Plugin comes handy.
The document opened is passable to the LaTeX recipe through the Build menu.
Git
Kate has a git client (not included in Kile!). The client is not documented in the handbook, unfortunately, but some info can be found here. What I consider important are the Show Diff and File history functions.
There is not much to configure, but for big documents after several compilation cycles version
control will get heavy and messy for sure. LaTeX engines output quite some files, and it is useful
to edit .gitignore
accordingly (see docs on gitignore). I
usually track only bibliographies and TeX files, thus to ignore everything else negated patterns are
useful:
*
!*.tex
!*.bib
I won’t advocate git for collaborative work, never tried it. Tips on how to do it properly are found elsewhere, but Overleaf is a better tool, probably. What I like is writing in sections with meaningful commit messages. The commit history becomes then a high-level description of how the text has evolved.