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

“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!

Creating an Online Academic Portfolio with LaTeX and TeX4ht

This was originally asked on TeX.SX, the requirements being:

Any one know of a good script to turn a bibtex file into a nice academic portfolio that:

  • links to electronic versions where known (from url or doi)
  • works with local files (e.g. with bibdesk’s format or otherwise)
  • automatically creates a thumbnail of the first page
  • and generally produces a polished web page suitable for showing off your work?

Well, I maintain my own online publication list by generating the HTML code from my BibTeX, using BibLaTeX, Biber and TeX4ht. So my answer to the above question was a quick modification of my own workflow, adding Ghostscript to the mix to generate thumbnail images of the papers. The output looks like this: (The publication lists can be split according to their types)

(BibLaTeX is a complete reimplementation of the bibliographic facilities provided by LaTeX in conjunction with BibTeX. It’s very flexible, and many find it easier to deal with compared to the BST language. Biber is the replacement of the BibTeX binary, for users of BibLaTeX.)

The source codes can be downloaded here as a .zip file. Further elaborations follow.

The Bibliography File

Back to the task at hand. First we have the BibTeX file, the content of which is pretty much the norm, except that I used the custom BibLaTeX field to hold the local PDF file name. My publications.bib contains entries like:

@ARTICLE{Lim:Ranaivo:Tang:2011,
author = {Lim, Lian Tze and Ranaivo-Malan\c{c}on, Bali and Tang, Enya Kong},
title = {Low Cost Construction of a Multilingual Lexicon from Bilingual Lists},
journal = {Polibits},
year = {2011},
volume = {43},
pages = {45–51},
url = {http://polibits.gelbukh.com/2011_43/43-06.htm},
usera = {LLT-polibits.pdf}
}

The LaTeX Source File

Next is the portfolio.tex file, in which I set up a hook at every bibliography item to include the first page of the file pointed to by usera. I’ve also added a bibmacro called string+hyperlink, to make the publication title link to the url or doi field if these are available, as shown in this answer.

\documentclass{article}
\usepackage[backend=biber,bibstyle=authoryear,sorting=ydnt]{biblatex}
\usepackage{graphicx}
\bibliography{publications}
\usepackage{hyperref}

\ExecuteBibliographyOptions{doi=false,url=false}
\newbibmacro{string+hyperlink}[1]{%
\iffieldundef{url}{%
\iffieldundef{doi}{#1}{\href{http://dx.doi.org/\thefield{doi}}{#1}}}
{\href{\thefield{url}}{#1}}}
\DeclareFieldFormat*{title}{\usebibmacro{string+hyperlink}{#1}}

\newbibmacro{usera}{%
\iffieldundef{usera}{}{%
\savefield*{usera}{\filename}%
\usebibmacro{string+hyperlink}{\includegraphics[width=100pt]{\filename}}\\}%
}
\AtEveryBibitem{\usebibmacro{usera}}

\begin{document}
\section{My Academic Portfolio}
\nocite{*}
\printbibliography[title={Articles},type={article}]
\printbibliography[title={Conference Proceedings},type={inproceedings}]

\end{document}

TeX4ht Configuration File

I then set up a TeX4ht personal configuration file, called portfolio.cfg (included in the .zip file). It contains some simple CSS, and tells TeX4ht to convert the first page of the local PDFs into PNGs using ghostscript. (So yes you will need to have ghostscript installed for this to work.)

Generating the HTML

Right, now we can run the following commands:

$  htlatex portfolio “portfolio”
$  biber portfolio
$  htlatex portfolio “portfolio”

And you should then get portfolio.html, which you can further embellish with more CSS. Well that was fun!