Skip to content

Commit 4b01848

Browse files
committed
New blog post about groff ms, refer, and APA; also reduced line-height in main.scss to 150%
1 parent 156e3fa commit 4b01848

File tree

6 files changed

+546
-32
lines changed

6 files changed

+546
-32
lines changed

_posts/2025-02-20-groff-apa.md

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: post
33
title: Guide to APA with groff ms and refer
4-
date: 2025-02-20
4+
date: 2025-02-06
55
categories: groff, ms, refer, macro, tmac, APA, style guide, pdf
66
permalink: /groff-apa
77
---
@@ -23,8 +23,8 @@ permalink: /groff-apa
2323
- [Default Fonts](/groff-apa#defaultfonts)
2424
- [Custom Fonts](/groff-apa#customfonts)
2525
- [Font Size](/groff-apa#fontsize)
26-
- [Font Style](/groff-apa#fontstyle)
2726
- [Line Spacing](/groff-apa#linespacing)
27+
- [Font Style](/groff-apa#fontstyle)
2828

2929
[In-text Citation](/groff-apa#intextcitation)
3030
- [Parenthetical Citation](/groff-apa#parentheticalcitation)
@@ -43,17 +43,17 @@ permalink: /groff-apa
4343

4444
# Preface <a name=preface></a>
4545

46-
I think every student who has been through college has had to write an essay with citations and referencing for all their sources for a mandatory prerequisite class, and I was no exception to this.
46+
Many colleges give students a mandatory class where they learn how to cite and do referencing in essays.
4747

48-
Just as a fun little challenge, I wanted to write my essay using [Neovim](https://neovim.io), the same terminal text-editor I code on and write blogs for my website with, so I had to find a word processor that can compile documents from plaintext (unlike What-You-See-Is-What-You-Get (WYSIWYG) word processors, such as [LibreOffice](https://www.libreoffice.org) [Writer](https://www.libreoffice.org/discover/writer)). As you could tell from the title of this blog post, I chose to use [groff](https://www.gnu.org/software/groff) for that task.
48+
For my essay, I wrote it using [Neovim](https://neovim.io), the same terminal text-editor I code on and write blogs for my website with, and that would not have been possible without a word processor that can compile documents from plaintext (unlike What-You-See-Is-What-You-Get (WYSIWYG) word processors, such as [LibreOffice](https://www.libreoffice.org) [Writer](https://www.libreoffice.org/discover/writer)). As you could tell from the title of this blog post, I used [groff](https://www.gnu.org/software/groff) to accomplish this.
4949

50-
You do not have to be writing in APA to find this guide helpful, as it goes through where many of the things that you will need to change are and explains how to change them. Just adapt some of the specific changes made in this guide to suit your needs.
50+
Although some of the modifications detailed in this guide are specific to APA, you do not have to be writing in APA to find this guide helpful. Just adapt some of the specific changes made in this guide to suit your style guide.
5151

5252
This blog guide mainly just serves to compile all the relevant research I had done into a simple step-by-step solution I can easily follow when I want to use groff to write essays in APA again, but it also hopes to help others who were in the same spot I was save themselves some time and frustration that I had to go through when figuring things out by myself for the first time.
5353

5454
I made a [Github repository](https://github.com/de-soot/groff-apa) as a companion to this guide. It gives an example of the final generated output so you know exactly what you are going to get out of this. The source files included in the repository have some extra comments to help readability and can also be used as a template to quickly set things up to just get started writing.
5555

56-
A fun little fact about this blog post: this is actually my second time writing this blog post because I lost the first one after almost finishing it.
56+
A fun fact about this blog post: this is actually my second time writing this whole thing because I frustratingly lost the first one in the dumbest way possible. I accidentally deleted the folder containing it because I forgot that I put it in the folder. Unfortunately, it was already gone by the time I realised due to the auto-emptying routine of my Trash folder scheduled to run once every hour.
5757

5858
# Introduction <a name=introduction></a>
5959

@@ -110,7 +110,7 @@ Many lecturers demand assignments to be submitted in double-spaced Times New Rom
110110

111111
## Font Family <a name=fontfamily></a>
112112

113-
By default, groff already outputs text in your [device's default serif font family](https://www.gnu.org/software/groff/manual/groff.html.node/Using-Fonts.html) (typically Times New Roman), but sometimes (very rarely, in my experience) lecturers prefer sans-serif or even monospace in some strange cases.
113+
By default, groff already outputs text in your [device's default serif font family](https://www.gnu.org/software/groff/manual/groff.html.node/Using-Fonts.html) (typically Times New Roman), but sometimes (very rarely, in my experience) lecturers prefer sans-serif or even monospace in some cases.
114114

115115
### Default Fonts <a name=defaultfonts></a>
116116

@@ -142,14 +142,22 @@ Installing custom fonts for groff is a little bit trickier; I have not been able
142142

143143
## Font Size <a name=fontsize></a>
144144

145-
The default font size in groff is a little bit less than 12pt ([10pt](https://www.gnu.org/software/groff/manual/groff.html.node/Manipulating-Type-Size-and-Vertical-Spacing.html), to be exact), but it is very easy to change. Simply add this line to your plaintext document:
145+
The default font size in groff is a little bit less than 12pt ([10pt](https://www.gnu.org/software/groff/manual/groff.html.node/Manipulating-Type-Size-and-Vertical-Spacing.html), to be exact), but it is very easy to change. Simply add this line to your plaintext document to change the font size to 12pt:
146146

147147
```
148148
.nr PS 12
149149
```
150150

151151
As for what `PS` stands for, it probably means something like "Point Size"; `.nr` stands for "Number Registers".
152152

153+
## Line Spacing <a name=linespacing></a>
154+
155+
All parts of an APA-styled paper [should be double-spaced](https://apastyle.apa.org/style-grammar-guidelines/paper-format/line-spacing). By default, groff uses [120% of font size](https://www.gnu.org/software/groff/manual/groff.html.node/Manipulating-Type-Size-and-Vertical-Spacing.html) as vertical spacing. Fortunately, changing this to double-spacing is just as simple as changing the font size: just set the vertical spacing (`.nr VS`) to double your font size (`.nr PS`).
156+
157+
```
158+
.nr VS 24
159+
```
160+
153161
## Font Style <a name=fontstyle></a>
154162

155163
Here is how to make your text **bold**,
@@ -176,17 +184,9 @@ And to set it back to normal:
176184
.ft R \" Stands for Regular or Roman
177185
```
178186

179-
## Line Spacing <a name=linespacing></a>
180-
181-
All parts of an APA-styled paper [should be double-spaced](https://apastyle.apa.org/style-grammar-guidelines/paper-format/line-spacing). By default, groff uses [120% of font size](https://www.gnu.org/software/groff/manual/groff.html.node/Manipulating-Type-Size-and-Vertical-Spacing.html) as vertical spacing. Fortunately, changing this to double-spacing is just as simple as changing the font size: just set the vertical spacing (`.nr VS`) to double your font size (`.nr PS`).
182-
183-
```
184-
.nr VS 24
185-
```
186-
187187
# In-text Citation <a name=intextcitation></a>
188188

189-
It is finally about time to start getting into the actual citations after all that setting-up.
189+
Now that everything is set up, we can start to get into the citations.
190190

191191
refer uses numbered footnotes by default, but APA wants the author(s) and date included in their in-text citations. This section will cover how to do exactly as APA says.
192192

@@ -295,7 +295,7 @@ Documentation for what each of the `ref*spec!N` mean can be found in the comment
295295

296296
The values for the letters after the `ref*spec!N` are specified in the bibliography file linked in the refer block (`ref.bib`).
297297

298-
Rearranging `D` (Date) into the correct order (right after `A` (Author(s)) and before `T` (Title)):
298+
Rearranging `D` (date) into the correct order (right after `A` (author(s)) and before `T` (title)):
299299

300300
```
301301
.ds ref*spec!0 Q A D T S V N P I C O
@@ -307,7 +307,7 @@ Rearranging `D` (Date) into the correct order (right after `A` (Author(s)) and b
307307

308308
## Punctuation <a name=punctuation></a>
309309

310-
Switching the order of the fields messes up the hard-coded punctuation order, but there are some other defaults that do not follow APA guidelines.
310+
Switching the order of the fields messes up the hard-coded punctuation order, but there are also some defaults that do not follow APA guidelines.
311311

312312
Go to lines 59--73 of `refer-ms.tmac`, where you will find this:
313313

@@ -383,16 +383,54 @@ This is how it looks like after some changes:
383383

384384
The list below details the changes:
385385

386-
- In the `.ds ref*spec!J` row, its `arg 1` is changed from a comma (`,`) to a period (`.`) to add a period after the Title field.
387-
- In the `.ds ref*spec!T` row, `\\*Q` and `\\*U` are removed to remove the opening and closing double quotation marks, respectively, around the Title field.
386+
- In the `.ds ref*spec!J` row, its `arg 1` is changed from a comma (`,`) to a period (`.`) to add a period after the title field.
387+
- In the `.ds ref*spec!T` row, `\\*Q` and `\\*U` are removed to remove the opening and closing double quotation marks, respectively, around the title field.
388388
- In both the `.ds ref*spec!T:0` and `.ds ref*spec!T:2` rows, `\fI` in `arg 3` and `\fP` in `arg 5` are removed to not italicise the text and because of redundancy (`\fP` resets font style back to normal), respectively.
389-
- In the `.ds ref*spec!V` row, its `arg 1` is changed from empty (`""`) to a comma (`,`) to add a comma after the Journal/Periodical field; its `arg 3` is changed from bold-ing (`\fI`) to italicising (`\fB`) the text.
390-
- All `\fP` in `arg 5` are moved to `arg 4` to make sure punctuations are not in bold or italics.
389+
- In the `.ds ref*spec!V` row, its `arg 1` is changed from empty (`""`) to a comma (`,`) to add a comma after the journal/periodical field; its `arg 3` is changed from bold-ing (`\fI`) to italicising (`\fB`) the text.
390+
- All `\fP` in `arg 5` are moved to `arg 4` to make sure the punctuations after each field are not in bold or italics.
391391

392392
### Authors, Ands & Ampersands <a name=authorsandsampersands></a>
393393

394+
By default, refer prepends "and" before the last author for more than 1 author. This is in contrast to the ampersand (&) that APA wants.
395+
396+
It should have been an easy fix to simply replace an "and" in one of the refer tmac files, but there is surprisingly no such thing to be found in any of the 2 files.
397+
398+
A solution to this is to simply manually type out the whole Authors field in the bibliography file:
399+
400+
```
401+
%K key123
402+
%A Author, A., Author, B. & Author, C.
403+
%D 2025
404+
%T Title
405+
%J Journal
406+
%V 123
407+
%N 456
408+
%P 999
409+
%O https://doi.org/12.34
410+
```
411+
412+
As opposed to how it would usually be:
413+
414+
```
415+
%K key123
416+
%A Author, A., Author, B. & Author, C.
417+
%D 2025
418+
%T Title
419+
%J Journal
420+
%V 123
421+
%N 456
422+
%P 999
423+
%O https://doi.org/12.34
424+
```
425+
426+
However, this solution conflicts with the format of in-text citations, as described in the subsection below.
427+
394428
#### Effect on Citations <a name=effectoncitations></a>
395429

430+
Due to having only one `%A` in the bibliography file, refer will think that there is only one author and the formatting for citations specified in the refer block will not work.
431+
432+
There is a solution for this. It is not pretty, but it works. Similarly to what you would do in the solution described in the Narrative Citations section, you would have to have 2 separate bibliography files: one that generates the correct citations (normal file with multiple `%A` for multiple authors) and one that generates the correct author field in the reference entry (modified file with only one `%A` for multiple authors). After compiling both versions of the document by changing the argument of `bibliography` in the refer block to switch between both of the bibliography files, use a PDF-editing tool to extract and combine the correct citations and references into one final file.
433+
396434
### Period Suppression <a name=periodsuppression></a>
397435

398436
By default, refer appends a period at the end of each entry. This means that a period is added after the last field that contains a DOI or URL, which APA has [explicitly stated to not do](https://apastyle.apa.org/instructional-aids/reference-guide.pdf).

_site/assets/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ h2 { color: #1a1a1a; font-family: sans-serif; }
203203

204204
h3 { color: #262626; font-family: sans-serif; }
205205

206-
p, ol, ul { font-family: serif; color: #333333; hyphens: auto; text-align: justify; line-height: 1.75; }
206+
p, ol, ul { color: #333333; font-family: serif; hyphens: auto; text-align: justify; line-height: 150%; }
207207

208208
@media (prefers-color-scheme: dark) { body { background-color: #262626; }
209209
h1 { color: #f2f2f2; }

0 commit comments

Comments
 (0)