Starbeamrainbowlabs

Stardust
Blog


Archive


Mailing List Articles Atom Feed Comments Atom Feed Twitter Reddit Facebook

Tag Cloud

3d 3d printing account algorithms android announcement architecture archives arduino artificial intelligence artix assembly async audio automation backups bash batch blender blog bookmarklet booting bug hunting c sharp c++ challenge chrome os cluster code codepen coding conundrums coding conundrums evolved command line compilers compiling compression conference conferences containerisation css dailyprogrammer data analysis debugging defining ai demystification distributed computing dns docker documentation downtime electronics email embedded systems encryption es6 features ethics event experiment external first impressions freeside future game github github gist gitlab graphics guide hardware hardware meetup holiday holidays html html5 html5 canvas infrastructure interfaces internet interoperability io.js jabber jam javascript js bin labs latex learning library linux lora low level lua maintenance manjaro minetest network networking nibriboard node.js open source operating systems optimisation outreach own your code pepperminty wiki performance phd photos php pixelbot portable privacy problem solving programming problems project projects prolog protocol protocols pseudo 3d python reddit redis reference release releases rendering research resource review rust searching secrets security series list server software sorting source code control statistics storage svg systemquery talks technical terminal textures thoughts three thing game three.js tool tutorial twitter ubuntu university update updates upgrade version control virtual reality virtualisation visual web website windows windows 10 worldeditadditions xmpp xslt

LaTeX templates for writing with the University of Hull's referencing style

Hello, 2024! I'm writing this while it is still some time before the new year, but I realised just now (a few weeks ago for you), that I never blogged about the LaTeX templates I have been maintaining for a few years by now.

It's no secret that I do all of my formal academic writing in LaTeX - a typesetting language that is the industry standard in the field of Computer Science (and others too, I gather). While it's a very flexible (and at times obtuse, but this is a tale for another time) language, actually getting started is a pain. To make this process easier, I have developed over the years a pair of templates for writing that make starting off much easier.

A key issue (and skill) in academic writing is properly referencing things, and most places have their own specific referencing style you have to follow. The University of Hull is no different, so I knew from the very beginning that I needed a solution.

I can't remember who I received it from, but someone (comment below if you remember who it was, and I'll properly credit!) gave me a .bst BibTeX referencing style file that matches the University of Hull's referencing style.

I've been using it ever since, and I have also applied a few patches to it for some edge cases I have encountered that it doesn't handle. I do plan on keeping it up to date for the forseeable future with any changes they make to the aforementioned referencing style.

My templates also include this .bst file to serve as a complete starting template. There's one with a full page title (e.g. for thesis, dissertations, etc), and another with just a heading that sits at the top of the document just like a paper you might find on Semantic Scholar.

Note that I do not guarantee that the referencing style matches the University of Hull's style. All I can say is that it works for me and implements this specific referencing style.

With that in mind, I'll leave the README of the git repository to explain the specifics of how to get started with them:

https://git.starbeamrainbowlabs.com/Demos/latex-templates

They are stored on my personal git server, but you should be able to clne them just fine. Patches are most welcome via email (check the homepage of my website!)!

Syntax highlighting and word wrapping code in LaTeX

For the longest time, I didn't think it was possible to syntax highlight code in LaTeX, but I was proven wrong a few months ago when I stumbled across the minted package, which uses pygments under-the-hood. Even better, it ships with texlive by default!

Recently, I had need to put it to use once more, and I encountered a bug in which my source code was too long for the line, but minted did not wrap it on to the following line. The solution was quite simple but definitely non-obvious, so I thought I'd make a quick post about it here.

To start with, minted works a lot like the lstlisting you might have used before:

An example block of syntax highlighted Javascript:

\begin{minted}{javascript}
"use strict";

export default async function(x, y) {
    return x + y;
}
\end{minted}

Pretty easy, right? But if you have a really long line (or lots of indentation), then it might overflow the edge of the page without wrapping. Thankfully there's an easy way to fix it that I discovered after digging around for a bit:

\begin{minted}[breaklines,breakanywhere]{javascript}
"use strict";

export default async function(x, y) {
    return x + y;
}
\end{minted}

....by adding [breaklines,breakanywhere] directly after \begin{minted}, we can get it to wrap onto the next line! Even better, we can use the same trick to also add line numbers for easy referencing later:

\begin{minted}[breaklines,breakanywhere,linenos]{javascript}
"use strict";

export default async function(x, y) {
    return x + y;
}
\end{minted}

The linenos option here causes minted to draw line numbers before each line of code. This also respects wrapped lines too, so they don't get all out of sync. Here's a sample of all of these tricks put together in action:

A screenshot of some Python code, syntax highlighted with minted. Some lines wrap onto multiple physical lines on the page. the code is part of a function that preprocesses text for GloVe.

I hope this helps someone out, because I know I find it very useful. I'll hopefully be posting another PhD update blog post soon for those who are eagerly await it - I know it's overdue!

Post a comment below if you have anything specific you'd like me to cover, and I'll do my best to make a post about it.

Art by Mythdael