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

Another year, another Cuti-cuti Malaysia customisable calendar created with LaTeX! (Well at least this year my updates are quarterly)

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.

Calendars for January, February 2021

Federal public holidays are highlighted in solid shaded pink circles, as in 12–13 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. 1 February (Federal Territory Day) which is a public holiday in Kuala Lumpur, Putrajaya and Labuan, 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. Month illustrations in the sample calendar are created by GraphicMama and distributed by Smashing Magazine under Creative Commons Attribution 3.0 Unported.

Happy New Year 2021!

Pruning .bib files with JabRef

BibTeX files are quite amazing when you think about it: It’s a plain text file, acting as a format-independent database, holding information about various types of published (or unpublished) artifacts, to support the generation of citations in LaTeX documents.

BibTeX styles typically ignore fields that it doesn’t support, so you can add arbitrary field names to hold whatever additional information you want about each item, e.g. “annote“, “keywords“, “abstract“, etc. Some reference management software even take to embed an entire PDF file as a binary string as a field (e.g. “bdsk-file-1“) right inside the .bib file.

While this means you can use your .bib as a completely standalone reference library, it does mean that the .bib’s physical file size can get quite bloated, even to many MBs: bibliography processors like bibtex or biber would then take a much longer time reading and parsing the .bib file, even if they’re just going discard these field values. And if these fields contain special characters, like %, then bibtex/biber will likely choke and fail to process the entire .bib file correctly.

It may therefore make sense to prune your .bib file to remove these fields, to export a leaner .bib. Several Python scripts have been written for such purposes (e.g. this one), but if you happen to have a copy of JabRef it’s pretty nifty too, especially if you prefer a GUI tool.

  1. Click on any items in the .bib first, and then Ctrl-A (or Cmd-A on a Mac) to select all entries in the .bib.
  2. Click on the “Edit” menu and choose “Automatic field editor
  3. In the “Edit content” tab, specify/choose “abstract” for field name, then click “Clear field content“.
  4. Repeat step 3 for “keywords”, “annote”, “file”, “bdsk-file-1” and any other fields that you want to remove. Make sure that all entries are still selected; because this operation only applies to selected entries.
  5. Click “Keep Modifications” to close the dialog. Remember to Save the .bib to commit the changes to file.

Creating tiled background patterns

We’ve covered before how to use the wallpaper package to create a background for your documents using, amongst others, tiled images in a previous post. But at times I really want to create patterns from existing LaTeX font ornaments or TikZ drawings, rather than using an extra image file.

The tcolorbox package has a fill tile picture option that can be used with arbitrary TikZ code:

tcolorbox-fill-tile-picture

But from experience, repeatedly running TikZ code can result in long compilation times, especially if you were planning to use design a tile pattern as the background to all pages. Saving a TikZ tile drawing as a LaTeX box, and then repeating that, would compile much faster.

So, OK, let’s give this a try and design some tiles! *crackles knuckles*

Designing a Tile

I’m no designer, so I thought I would just fumble along and try to mock up something first, before cropping/clipping things down to the required tile element. The adforn package provides some subtle ornaments, so I’ll use those as a start to play around on a grid to help me lay things out:

\usepackage{adforn}
 
\begin{document}
\definecolor{blossompink}{HTML}{FFD7D7}
\definecolor{fruitgold}{HTML}{FFEEBE}
\definecolor{stictchbrown}{HTML}{E7D192}
 
\begin{tikzpicture}[x=1cm,y=1cm,domain=0:3]
\draw[step=1cm,black!10,very thin] (0cm,0cm) grid (3cm,3cm);
\foreach \x in {0,1} {
  \foreach \y in {0,1} {
     \node[font=\Huge,text=blossompink] at (2*\x, 2*\y) {\adforn{5}};
     \node[font=\Huge,text=fruitgold] at (2*\x+1, 2*\y+1) {\adforn{35}};
   }
}
\begin{scope}[dashed,stictchbrown]
  \draw plot (\x,\x-1);
  \draw plot (\x,\x+1);
  \draw plot (\x,-\x+1);
  \draw plot (\x,-\x+3);
\end{scope}
\end{tikzpicture}

scratch-design-1 That looks pretty good to me! And I only need a 4-by-4 unit of this sketch (the dark gray square) to make me a tile, which I can get with a \clip (0,0) rectangle (2,2); at the start of the TikZ code.

This can then go into a \savebox for later use:

\newsavebox{\tileone}
\sbox{\tileone}{%
  \begin{tikzpicture}[x=1cm,y=1cm]
  \clip (0,0) rectangle (2,2);
  \foreach \x in {0,1} {
    \foreach \y in {0,1} {
       \node[font=\Huge,text=blossompink] 
         at (2*\x, 2*\y) {\adforn{5}};
       \node[font=\Huge,text=fruitgold] 
         at (2*\x+1, 2*\y+1) {\adforn{35}};
     }
  }
  \begin{scope}[dashed,stictchbrown]
    \draw plot (\x,\x-1);
    \draw plot (\x,\x+1);
    \draw plot (\x,-\x+1);
    \draw plot (\x,-\x+3);
  \end{scope}
  \end{tikzpicture}%
}

If you \usebox{tileone}, you’ll see this:
tile-1

And we can now use this with tcolorbox‘s fill tile picture option:

\begin{tikzpicture}
\path[draw,fill tile picture={%
  \node[inner sep=0pt,outer sep=0pt,fill=blue!40!black]
       {\scalebox{0.5}{\usebox{\tileone}}};
}] 
(2.75,-0.75) -- (3,0) -- (2.75,0.75)
\foreach \w in {45,90,...,315}
{ -- (\w:1.5cm) } -- cycle;
\end{tikzpicture}

This can also be easily made into a whole-page background. I usually (ab)use the page header to get it in:

\usepackage{fancyhdr}
\usepackage{tikzpagenodes}
\fancyhf{}
\renewcommand{\headrule}{}
\fancyhead[L]{%
\begin{tikzpicture}[overlay,remember picture]
  \path[fill tile picture={%
    \node[inner sep=0pt,outer sep=0pt] {\usebox{\tileone}};
  }] (current page.south east) rectangle (current page.north west);
  \fill[opacity=0.4,white] ([shift={(-1em,1em)}]
        current page text area.north west) rectangle
           ([shift={(1em,-1em)}]current page text area.south east);
\end{tikzpicture}
}
\begin{document}
\thispagestyle{fancy}

pagebg-tileone-fs8pagebg-tilethree-fs8

The extra thumbnails shows designs that uses pgfornament-han and pgfornament just for fun; might be a bit over the top there though. Enjoy designing your new backgrounds, but do take care not to be over-flamboyant to the point of being too distractive, and repeating things too many times on too many pages will still take a long time to compile, despite already using \usebox!

The Future of GayaUKM

I first created GayaUKM, a LaTeX document class and template for authoring theses following the formatting guidelines of University Kebangsaan Malaysia (UKM) in 2013, on a commission by Pusat Pengurusan Siswazah, UKM.

With inputs from PPS, faculty and students from UKM, GayaUKM is now at v1.4. Unfortunately, I no longer quite have the time to continue maintaining and updating GayaUKM after v1.4.

I am therefore very glad to announce that Dr Mohd Hairi Mohd Zaman, from UKM’s Department of Electrical, Electronic and Systems Engineering, have agreed to take up the mantle to maintain GayaUKM. Thank you, Hairi! The new Github repo address is at https://github.com/mohdhairimohdzaman/GayaUKM.

I thank also UKM’s PPS thesis committee, especially Dr Asyraf and Dr Zambri, for their past support of GayaUKM and for helping to spread the word about LaTeX among Malaysian academics and students.

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

Erm… I am sorry that I had neglected this blog to the point that it’s now the annual announcement for the Cuti-cuti Malaysia calendars 😅

But anyway, here it is. You can download the PDF customised for Penang here.

PG-2020

Federal public holidays are highlighted in solid shaded pink circles, as in 25–26 January. 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. 1 February (Federal Territory Day) which is a public holiday in Kuala Lumpur, Putrajaya and Labuan, but not in Penang.

This year I’ve tried to add some code that automatically detects if the Monday after a public holiday (for states like Penang, Selangor…) would also be a holiday. For example, 26 Jan falls on a Sunday; therefore 27 Jan is also a holiday: this is highlighted in the calendar by a pink shaded circle but without a solid outline.

School holidays are also highlighted, though not shown in the above sample images.

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 last year’s post for instructions on how to customise your calendar.

This year I’ve also updated the cdcalendar class so that the giant option would generate mini calendars for the previous and next month, upon a feature request from my daughter. (Children can often come up with the most useful and practical feature requests!) While implementing it, I was pleasantly surprised that TikZ’s calendar would correctly print December 2019’s calendar when presented with a date like 2020-0-01, and January 2021’s calendar when given 2020-13-01!

BTW if you would like to use Bahasa Melayu month headings instead, change

\documentclass[17pt,british,giant]{cdcalendar}

to

\documentclass[17pt,nobabel,giant]{cdcalendar}
\usepackage[bahasam]{babel}
\usepackage{ms-mod}

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.

Happy New Year 2020!

Cuti-cuti Malaysia: 2019 calendar with Malaysian public and school holidays

I made a calendar marked with Malaysian holidays for personal use, and then decided to make it public. It uses my LaTeX CD calendar template. Here are some sample pages:
February 2019 calendar marked with Malaysian holidays, customised for PenangMarch 2019 calendar marked with Malaysian holidays, customised for Penang
Download Cuti-cuti Malaysia 2019 Calendar for Penang
Download LaTeX source code files

This has been customised specifically with Penang in mind, so state holidays observed in Penang are marked with filled purplish circles, while holidays observed in other states are marked with hollow circles. National holidays are marked with filled red circles.

Customisations

Here are the LaTeX source code files if you’d like to re-generate the calendar for a different state, or if you’d like to customise it further. You can also clone the template project if you have an Overleaf account.

Calendars for other states or federal territories

If you’d like to generate a calendar with state holidays marked for a different state, Download the source code, change the line

\def\mylocation{Penang}

to a different state or federal territory, and recompile the .tex file with XeLaTeX. For example:

\def\mylocation{Kuala Lumpur}

Valid values for \mylocation: Kedah, Johor, Kelantan, Terengganu, Malacca, Negeri Sembilan, Pahang, Penang, Perak, Sabah, Sarawak, Selangor, Kuala Lumpur, Labuan, Putrajaya.

Add Chinese lunar calendar

You can also uncomment this line in the .tex file’s preamble:

\providetoggle{chinese-lunar}\toggletrue{chinese-lunar}

The generated calendar would then include the Chinese lunar calendar.
February 2019 calendar marked with Malaysian holidays and Chinese lunar calendar, customised for PenangMarch 2019 calendar marked with Malaysian holidays and Chinese lunar calendar, customised for Penang
Download Cuti-cuti Malaysia 2019 Calendar for Penang, with Chinese lunar calendar

Add your own events

You can add your own events to the calendar and define your own styles for their markers. For example:

\tikzset{personal/.style={text=YellowGreen!50,font=\Large}}
\tikzset{work/.style={fill=SkyBlue!50,shape=cloud,aspect=1.5}}
 
\begin{monthCalendar}{2019}{01}
\event[mark style=personal,marker=\faBirthdayCake]{2019-01-12}{}{Someone's birthday}
\event[mark style=work]{2019-01-23}{2019-01-24}{Business trip}
\end{monthCalendar}

would produce this output in the January calendar:

Adding your own events to the calendar

Changing or removing the images

All photos in this sample, in the flickr/ folder, were downloaded from Flickr and are licensed under Creative Commons licenses. You can replace them with your own images for your own use. Remember to change the \graphicspath{{flickr/}} line if you use a different folder for the images.

If you do not want any illustrations, simply remove the \illustration commands before each month’s calendar.

For further information about the underlying cdcaleandr class and template, see this blog post or its Github repository.

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 and 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.

Happy New Year 2019!

“Why is LaTeX doing all the APA citations wrong?”

[This post from 2017 is about APA6. For APA7 please see Using APA7 with umalayathesis and Using APA7 with usmthesis.]

Over the years I get emails asking the above question, especially in thesis templates where the university requires the APA citation and referencing style, which I usually implement with

\usepackage[natbibapa]{apacite}
\bibliographystyle{apacite}

Alternatively biblatex can also be used:

\usepackage[backend=biber,natbib,style=apa]{biblatex}

“If LaTeX is so great, why is it making all the APA citations wrong? It should always be (Author1, et al., 2012), but it keeps giving me (Author1, Author2, & Author 3, 2012) when I cite this entry. Should I stop using LaTeX?”

Riiight. Is apacite really doing things wrongly? First let’s see what the APA6 guidelines say about citations:

the first in-text citation for a work with three to five
authors/editors
includes all of the names of the authors/editors, subsequent citations include only the first author’s/editor’s surname, followed by et al. and the year.

So the first time you cite a source with 3 ≤ # of authors ≤ 5, it should come out as (Author1, Author2, & Author 3, 2012). It’ll only come out as (Author1, et al., 2012) if you cite it again later. The apacite and biblatex-apa packages both do exactly this.

Incidentally if it does come out as (Author1 et al, 2012) the first time you cite it: are there are 6 authors or more for this source? Then yes, this is correct; this is exactly what the APA6 guidelines say to do with such sources. But if this source has 3 ≤ # of authors ≤ 5 and the first citation in your thesis (it’s there on page 1 of Chapter!) is still the abbreviated version (Author1 et al, 2012), then the most likely reason is that the true “first citation” has already appeared somewhere in the Table of Contents, List of Figures, or List of Tables, via a \section etc or a \caption!

In this case I’d recommend that you use an optional argument with your sectional heading or caption, which will be used in the table of contents and lists of figures/tables:

\section[The Old Approach]{The Old Approach \citep{Smith:etal:1982}}
\caption[Old Model]{Old Model \citep{Smith:etal:1982}}

So that the list entries in the front matter will not have citations; but the sectional headings and captions in the main text do.

But there is another scenario: not-quite twins, i.e. they are actually authored by different teams of authors even though the first author is the same person; or even if same group of authors, but in a different order.

[H]ow to cite multiple articles by the same authors that were published in the same year so that everyone can easily tell them apart. […] [L]owercase letters are added after the year (2011a, 2011b, etc.), and the references are alphabetized by title to determine which is “a” and which is “b.” […]

However, be careful that your references are true identical twins. That is, the method described above applies only when all author names are the same and appear in the same order. If any of the names or the order is different, then the references are distinguished in a different way: by spelling out as many author names as necessary to tell them apart.

For example: The first source by Adam Smith, Mark Jones, Paul Stark, Someone Blah, 1982 (I ran out of ideas for names)
and the second source by Adam Smith, Foo Bar, Hiya Hill, Mary Doe, 1982

In cases like this, even on subsequent citations, they cannot both be shortened to (Smith, et al., 1982a) and (Smith, et al., 1982b), because that may be ambiguous, implying that both papers are written by the exact  same team of authors in 1982. Instead, they would be cited as (Smith, Jones, et al., 1982) and (Smith, Bar, et al.,1982). Again, this is what apacite and biblatex-apa do.

“But the IPS/Graduate Office/my supervisor insist that all the citations must be shortened to (Author1, et al., 1982) everywhere, otherwise I am not allowed to submit my thesis!”

Yeah, that’s what’s most crucial, isn’t it… There is a way to get a “half-compliant” APA citation scheme. You can either use the \shortcite command provided by the apacite package (thanks to Stefan for reminding me about this in the comments!), or use the apalike bibliography style instead:

\usepackage{natbib}
\bibliographystyle{apalike}

But never say apacite is doing it wrong—it’s actually doing its job very nicely; but certain Graduate Offices and supervisors don’t want the full APA format!

Lest we forget: Typography & LaTeX

Martins Bruveris recently gave an introductory lecture on LaTeX at Brunel University, and the deck was based on my previous LaTeX: More Than Just Academic Papers and Theses slides. (Suffice to say that I’m extremely happy that people are still reading it since I first made it in 2011—I’ve since updated it a bit.)

I particularly like how Martins highlighted how important typography is in retaining the readers’ (ahem supervisors, examiners, reviewers…) interest/attention. That’s so true—I remain certain that I received an award for my paper at a student workshop, partly (or perhaps majorly) because I used LaTeX. One of the panels commented “it’s a very clear, very nice paper—not sure why but it was just very enjoyable to read.”

"Your paper makes no sense, but it's the most beautiful thing I have ever laid eyes on."
Image courtesy of somethingofthatilk

Lest we’ve forgotten at times amid all the exciting new packages in recent years that let us do various cool things in LaTeX, typography is why Knuth created TeX in the beginning, and why some (I’ll acknowledge not all) users prefer LaTeX over word processors. Martins included this quote on typography in his slides:

Typography matters because it helps conserve the most valuable resource you have as a writer—reader attention.
Attention is the reader’s gift to you. That gift is precious. It is finite. And if you fail to be a respectful steward of that gift, it will be revoked.
(Matthew Butterick, Typography for Lawyers)

I would add this quote by Robert Bringhurst in the opening chapter to The Elements of Typographic Style:

Like oratory, music, dance, calligraphy—like anything that lends its grace to language—typography is an art that can be deliberately misused. It is a craft by which the meanings of a text (or its absence of meaning) can be clarified, honored and shared, or knowingly disguised.

and later in Chapter 10:

Writing begins with the making of meaningful marks. That is to say, leaving the traces of meaningful gestures. Typography begins with arranging meaningful marks that are already made. In that respect, the practice of typography is like playing the piano—an instrument quite different from the human voice.

And personally, I do think writings convey the experience knowledge of humankind (I know that sounds a bit pompous, spare me the rod), and deserve to be typeset with ultimate quality for an enjoyable reading experience!