Are you loading incompatible packages with a template?

(Reader, this is going to be a long, ranty, rambling piece; I apologise beforehand.)

There are LaTeX packages for typesetting all kinds of things. And sometimes, there are more than one LaTeX  packages that can do (almost) the same thing — but are not compatible with each other so you often cannot load them at the same time.

If you had been given a template e.g. for typesetting your report, thesis, conference or journal manuscript, be sure to read through the instructions and example code provided in the .tex file. There may be important information re the specific packages that had already been loaded by the template or class to help you typeset certain elements (e.g. algorithms; code listings; sub-figures or sub-tables) — you should then use the commands and environments provided by these packages (i.e. the packages that the template intend you to use), and avoid loading other packages that provide similar functions. Continue reading

Cuti-cuti Malaysia: Customisable state-by-state holiday calendar for 2024

Annual cuti-cuti Malaysia calendar! This year I’ve made quite a lot of updates to the underlying code for cdcalendar; the documentation has been shaken up quite a bit too.

The Cuti-cuti Malaysia 2024 calendar LaTeX files is available as an Overleaf read-only project here. By default, this generates an A4 landscape calendar that highlights national and Penang state public holidays and school holidays, along with the nongli (Chinese lunisolar) calendar.

Cuti-cuti Malaysia January 2024 for Penang, A4 landscape without mini calendars
Cuti-cuti Malaysia January 2024 for Penang, A4 landscape without mini calendars ([giantsolo, landscape])
If you’d like to generate a calendar for a different state, or choose a different layout or size, or use your own pictures, or add/mark your own events, you can clone that Overleaf project to edit your own copy; or download the source files to edit on your own local LaTeX installation.

So, a quick recap of what this is: depending on which state (negeri) or federal territory (wilayah persekutuan) you’re in, the public holidays and school holidays would differ. It can get really hard to keep up with which holiday your local bank or your kid’s school is observing… so I decided to make my own calendar that would mark the holidays with different colours, depending on which state you’re in. Continue reading

Did you know — you can now use CSL reference styles in LaTeX

(I like this so much that I’ll repost it here after writing about it on the Overleaf blog!)

It’s now possible to use Citation Style Language stylesheets (.csl files) to format citations and reference lists in LaTeX documents! Make sure your LaTeX packages are reasonably up-to-date for this to work.

You can find .csl styles here (let’s use uoy-archaeology-jsm.csl as an example); and put it in the same folder as your .tex file. Load the citation-style-language package in the preamble:

\documentclass[12pt]{article}
\usepackage{citation-style-language}
\cslsetup{style = uoy-archaeology-jsm}
\addbibresource{researchDesign.bib}
 
\begin{document}
... This combination of data from multiple sources may present problems 
in the categorisation and comparison of sites across the region as a 
whole, in particular the Scottish region where few radiocarbon dates are
available and many site not been classified by date 
\cite{elliot-email-2023,beckensall-northumberland-2005}
 
\printbibliography
 
\end{document}

Then after compiling with latex/pdflatex/xelatex, instead of running bibtex to process the citations and .bib file, run the citeproc-lua command instead. Follow up with the usual one or two more runs of latex/pdflatex/xelatex, and watch your citations and references appear. A .bbl file will be generated, which you can include in your manuscript submissions to journals.

But if you’re compiling with LuaLaTeX, things will “just work” with just a single compile.

This will be useful if your institution or journal requires a particular reference style that doesn’t have a corresponding BibTeX or biblatex style file, but does have a CSL style file.

Cuti-cuti Malaysia: Customisable State-by-state Holidays Calendar for 2023

I’ll cut to the chase: Cuti-cuti Malaysia calendar for 2023!

PDF for Penang version: download here.

For other states download the .zip or clone this Overleaf project to your own Overleaf account. Change

\def\mylocation{Penang}

to e.g.

\def\mylocation{Selangor}

If you would just like a calendar without the Malaysian holidays and/or Chinese lunisolar calendars, see this Github repo or this Overleaf template.

See this post for instructions on how to customise your calendar.

Data sources

The calendar data used in this sample were obtained from the following sources, and I cannot guarantee their accuracy and correctness.

  1. Malaysian public holiday data was sourced from the Google Calendar here using the Google Calendars API, then converted to a tab-separated values file.
  2. Malaysian school holiday data was sourced from the Malaysian Ministry of Education’s webpage.
  3. Chinese lunar calendar data was sourced from here, converted to a CSV file and Simplified Chinese and some minor editing for typesetting purposes (inserting \\ for line breaks.
  4. Photos in the sample calendar are sourced from Pexels and provided under the Pexels License.

Using APA7 with usmthesis

Following up from the previous post Using APA7 with umalayathesis, but about usmsthesis. Likewise, I am hoping (against hope?) that one day, apacite package will be updated to support APA7, so that usmthesis.cls won’t need to undergo overhauling either.

But until that day comes, if you need to use APA7 with usmthesis now, then it may actually be easier to make the following changes within usmthesis.tex itself (don’t modify usmthesis.cls).

Add these lines before \documentclass.

\RequirePackage{scrlfile}
\PreventPackageFromLoading{apacite,multibib}
\AfterClass{book}{
  \RequirePackage[style=apa,natbib]{biblatex}
  \let\bibsep\bibitemsep
  \addbibresource{mybib.bib}
}

Remove these lines from usmthesis.tex: (They may be far away from each other; look carefully for each line in your .tex)

\newcites{own}{List of Publications}
\bibliographystyle{apacite}
\bibliographystyleown{apacite}
\bibliography{mybib}

Where you had \bibliography{mybib}, write instead:

\printbibliography[heading=bibintoc]

If you have lists of your own publications, remove these lines too:

\nociteown{lim:2007,lim:latextypesetting}
\bibliographyown{mybib}

and write instead:

\begin{refsection}
\nocite{lim:2007,lim:latextypesetting}
\printbibliography[title={List of Publications},heading=bibintoc]
\end{refsection}

After making these changes, delete the previously generated .bbl files (if any) in the directory.

Then run pdflatex, biber, pdflatex, pdflatex. Note that the biber processor must be used instead of bibtex now.

(If compiling on Overleaf, it should all “just work” because the build tool knows which processor to use.)

Using APA7 with umalayathesis

Currently the umalayathesis class uses apacite to implement the bibliography style, but apacite supports only APA6. For full APA7 it would be necessary to use biblatex-apa; no BibTeX style for full APA7 exists yet.

I’m still hoping (against hope?) that one day, the apacite package will be updated to support APA7, so that umalayathesis.cls won’t need to undergo overhauling…

But for now, if you want to use full APA7, it may actually be easier to make the following changes within thesis.tex itself.

Add these lines before \documentclass:

\RequirePackage{scrlfile}
\PreventPackageFromLoading{multibib}
\providecommand{\newcites}[2]{}

Make sure to add the custombib option in the \documentclass declaration:

\documentclass[english,singlespacedlisttitles,custombib]{umalayathesis}

And then add these lines after \documentclass:

\usepackage[natbib,style=apa]{biblatex}
\addbibresource{myrefs.bib}
\setlength\bibitemsep{2\onelineskip}
\setlength\bibhang{0.5in}
\renewcommand{\bibfont}{\SingleSpacing}

Next remove or comment out these lines:

\bibliography{myrefs}
\nociteown{Lim:2009,Bond:etal:WordNetBahasa:2014}
\bibliographyown{myrefs}

Add instead:

\cftinserthook{toc}{PlainChapTocLines}
\cftinserthook{toc}{disableuppercase}
\printbibliography[heading=bibintoc,title=\refname]
 
\begin{refsection}
\nocite{Lim:2009,Bond:etal:WordNetBahasa:2014}
\printbibliography[heading=bibintoc,title=\listpubname]
\end{refsection}

If you are using the splitpubs environment to separate your publication list for journal articles and conference proceedings, then change your splitpubs in your .tex file to be:

\begin{splitpubs}
\begin{refsection}
\nocite{Bond:etal:WordNetBahasa:2014}
\printbibliography[heading=subbibintoc,title={List of Publications:}]
\end{refsection}
 
\begin{refsection}
\nocite{Lim:2009}
\printbibliography[heading=subbibintoc,title={Papers Presented:}]
\end{refsection}
\end{splitpubs}

After making these changes, delete the previously generated .bbl files (if any) in the directory.

Then run pdflatex, biber, pdflatex, pdflatex. Note that the biber processor must be used instead of bibtex now.

(If compiling on Overleaf, it should all “just work” because the build tool knows which processor to use.)

Cuti-cuti Malaysia: Customisable State-by-state Holidays Calendar for 2022

OK, time for another Cuti-cuti Malaysia calendar for 2022… and yes I’m shamelessly reusing text wholesale from last year’s post 🙂

You can download the PDF customised for Penang here. If you would just like a calendar without the Malaysian holidays and/or Chinese lunisolar calendars, see this Github repo or this Overleaf template.

Preview of first two months in the calendar

Federal public holidays are highlighted in solid shaded pink circles, as in 1–2 February. Public holidays that are applicable for your home state (Penang in the above example) would be highlighted in solid shaded purple circles, as in 1 January. Public holidays in other states (relative to your home state) are also highlighted, but only in a hollow purple circle. See e.g. 14 January (Birthday of Yang di-Pertuan Besar) which is a public holiday in Negeri Sembilan, but not in Penang. School holidays are highlighted in light orange.

If you’d like to generate your own calendar for your own home state, or to change the illustrations/fonts/colours/etc, you can download the source code and compile with XeLaTeX. If you have an Overleaf account, you can also visit my read-only project and clone it to your own Dashboard. See this post for instructions on how to customise your calendar.

Data sources

The calendar data used in this sample were obtained from the following sources, and I cannot guarantee their accuracy and correctness.

  1. Malaysian public holiday data was sourced from the Google Calendar here using the Google Calendars API, then converted to a tab-separated values file.
  2. Malaysian school holiday data was sourced from the Malaysian Ministry of Education’s webpage.
  3. Chinese lunar calendar data was sourced from here, converted to a CSV file and Simplified Chinese and some minor editing for typesetting purposes (inserting \\ for line breaks.
  4. Photos in the sample calendar are sourced from Pexels and provided under the Pexels License.

Happy New Year 2022!

Citations not starting from [1]?

So you’re writing your thesis, and you’ve made very sure to use \bibliographystyle{IEEEtran}, or another style that numbers your citations sequentially throughout your thesis. Of course you would then expect that the first citation in your first chapter is [1], right? Right? So why does it not start from [1] in your own thesis; the first citation is some random number [16] or something??

The most likely cause is that you’ve used a \cite{...} somewhere in your \section, \subsection etc., or in a \caption{...}. So the compiler would see these \cite first when they appear in the table of contents, list of figures and tables: and you would likely see your citations [1], … [16] appearing in those lists.

Citations not starting from [1]
Citations not starting from [1] in “main text” despite using IEEEtran bibliography style
A quick solution to get around this is to load \usepackage{notoccite} in your preamble: this would ensure that the sequential numbering of citations will not start in \tableofcontents, \listoffigures, \listoftables.

Demo using notoccite package
Sample code and output when using notoccite with citations

Happy LaTeXing!