Skip to content

Commit 3face87

Browse files
authored
Merge pull request #56 from de-soot/main
Corrections
2 parents d56420c + 1fb1c53 commit 3face87

File tree

4 files changed

+46
-120
lines changed

4 files changed

+46
-120
lines changed

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

Lines changed: 33 additions & 59 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-06
4+
date: 2025-02-07
55
categories: groff, ms, refer, macro, tmac, APA, style guide, pdf
66
permalink: /groff-apa
77
---
@@ -35,8 +35,6 @@ permalink: /groff-apa
3535
- [Space Between Entries](/groff-apa#spacebetweenentries)
3636
- [Field Ordering](/groff-apa#fieldordering)
3737
- [Punctuation](/groff-apa#punctuation)
38-
- [Authors, Ands & Ampersands](/groff-apa#authorsandsampersands)
39-
- [Effect on Citations](/groff-apa#effectoncitations)
4038
- [Period Suppression](/groff-apa#periodsuppression)
4139

4240
[Exporting as PDF](/groff-apa#exportingaspdf)
@@ -85,16 +83,18 @@ The first page does not have any headers (including page numbering) because grof
8583

8684
If you followed the steps on the previous section on the cover page, you might be confused as to why the first page after the cover page still does not have any page numbering while the page after it starts with the page numbering of '2'. This is because although groff started counting page numbers on the first page after the cover page, it still suppresses the first page by default.
8785

88-
When we used the `.RP no` macro to move the cover page information into its own page, we simply created a new "page 0" that groff does not know about (which is also why groff does not count it in the page numbering).
86+
When we used the `.RP no` macro (also needed for this section) to move the cover page information into its own page, we simply created a new "page 0" that groff does not know about (which is also why groff does not count it in the page numbering).
8987

90-
Conveniently, is another macro to help us fix this. Place `.P1` below `.RP no` to unsuppress the first page header (page numbering):
88+
There is another macro we can use to fix this. Place `.P1` below `.RP no` to unsuppress the first page header (page numbering):
9189

9290
```
9391
.RP no
9492
.P1
9593
```
9694

97-
Note that `.P1` does not work by itself without `.RP no`, likely because groff suppresses headers on any page with cover page information even if you make them empty by doing this:
95+
The `.RP no` macro is needed for this, but it produces a cover page. Use PDF-editing software to delete it if it is unwanted. Any tool can be used for this, but the best one I found is [PDFArranger](https://github.com/pdfarranger/pdfarranger).
96+
97+
`.P1` does not work by itself without `.RP no` likely because groff suppresses headers on any page with cover page information, even if you make them empty by doing this:
9898

9999
```
100100
.TL
@@ -166,18 +166,12 @@ Here is how to make your text **bold**,
166166
.ft B
167167
```
168168

169-
*italicised*,
169+
or *italicised*.
170170

171171
```
172172
.ft I
173173
```
174174

175-
or even ***both***!
176-
177-
```
178-
.ft BI
179-
```
180-
181175
And to set it back to normal:
182176

183177
```
@@ -192,7 +186,7 @@ refer uses numbered footnotes by default, but APA wants the author(s) and date i
192186

193187
## Parenthetical Citation <a name=parentheticalcitation></a>
194188

195-
After some research, I found a [blog post "no-tears" guide](https://preciouschicken.com/blog/posts/no-tears-references-groff), 2 [Github](https://github.com/Koshkov/groff-paper-template) [repositories](https://github.com/skurtulmus/refer-styles), and a post from the [GNU mailing list](https://lists.gnu.org) (which I cannot seem to find anymore). I extracted the refer block (denoted by `.R1` and `.R2`) from all those sources and combined them to make a frankenstein that works perfectly for most APA parenthetical citations:
189+
After some research, I found a [blog post "no-tears" guide](https://preciouschicken.com/blog/posts/no-tears-references-groff), 2 [Github](https://github.com/Koshkov/groff-paper-template) [repositories](https://github.com/skurtulmus/refer-styles), and a post from the [GNU mailing list archive](https://lists.gnu.org) (which I cannot seem to find anymore). I extracted the refer block (denoted by `.R1` and `.R2`) from all those sources and combined them to make a frankenstein that works perfectly for most APA parenthetical citations:
196190

197191
```
198192
.R1 \" Refer block start
@@ -210,7 +204,7 @@ no-label-in-reference # Do not display (Author(s), Date) like footnotes in refer
210204

211205
My lecturer luckily did not require me to use narrative citations, but yours might. If you do have to use narrative citation, unfortunately, refer does not have any support for narrative citations being alongside parenthetical citations. While it is possible to repurpose the citation formatting part of the refer block to change it from parenthetical to narrative, it would still not be possible to have both narrative and parenthetical citation on the same page.
212206

213-
The only practical solution I see to this problem is to keep the refer block as-is and write the narrative citations manually. This will require you to have a separate document for producing the referencing for the narrative citations, because refer will not make entries for them in the reference list as it will not recognise the narrative citations that you manually typed in, treating them like ordinary text. This also means that you need to generate 2 separate output PDFs and extract the correct reference list from the one without narrative citations to merge with the other one that does. Any PDF-editing tool can be used for this, but the best free and open-source one that I found was [PDFArranger](https://github.com/pdfarranger/pdfarranger).
207+
The only practical solution I can think of for this problem is to keep the refer block as-is and write the narrative citations manually. This will require you to have a separate document for producing the referencing for the narrative citations, because refer will not make entries for them in the reference list as it will not recognise the narrative citations that you manually typed in, treating them like ordinary text. This also means that you need to generate 2 separate output PDFs and extract the correct reference list from the one without narrative citations to merge (using PDF-editing software) with the other one that does.
214208

215209
# Reference List <a name=referencelist></a>
216210

@@ -252,7 +246,7 @@ Below is a list explaining each change made:
252246

253247
## Space Between Entries <a name=spacebetweenentries></a>
254248

255-
There is no space between reference entries by default, which can make it look cramped. This is already conforming to APA, but my lecturer wanted extra padding between the entries (even if that meant [breaking APA guidelines](https://apastyle.apa.org/style-grammar-guidelines/paper-format/reference-list)).
249+
There is no space between reference entries by default. This is already conforming to APA, but my lecturer wanted extra padding between the entries (even if that meant [breaking APA guidelines](https://apastyle.apa.org/style-grammar-guidelines/paper-format/reference-list)) and maybe yours might too.
256250

257251
Inside `refer-ms.tmac` on lines 44--45, you can find this:
258252

@@ -269,6 +263,28 @@ Inside `refer-ms.tmac` on lines 44--45, you can find this:
269263
..
270264
```
271265

266+
{%comment%}
267+
268+
### For Specific Entries <a name=forspecificentries></a>
269+
270+
For reference lists that span more than one page, some entries (especially large ones) may be split between 2 pages. While it would be easy to press the enter key a couple times in a WYSIWYG word processor, you should know by now that things are not going to be that easy in groff and refer.
271+
272+
To fix an entry being split between pages, first identify the entry above it and then add `TODO: I forgot how I did it` at the end of its `%O` line:
273+
274+
```
275+
%K key123
276+
%A Author, A.
277+
%D 2000
278+
%T Title
279+
%J Journal
280+
%V 123
281+
%N 456
282+
%P 789
283+
%O https://doi.org/123.456
284+
```
285+
286+
{%endcomment%}
287+
272288
## Field Ordering <a name=fieldordering></a>
273289

274290
The way refer orders the fields of each reference entry is hard-coded and different from what APA desires. More specifically, the date field is placed after the title field instead of being in between it and the author(s) field.
@@ -385,52 +401,10 @@ The list below details the changes:
385401

386402
- 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.
387403
- 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.
388-
- 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.
404+
- 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 the previous style), respectively.
389405
- 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.
390406
- All `\fP` in `arg 5` are moved to `arg 4` to make sure the punctuations after each field are not in bold or italics.
391407

392-
### Authors, Ands & Ampersands <a name=authorsandsampersands></a>
393-
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-
428-
#### Effect on Citations <a name=effectoncitations></a>
429-
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-
434408
### Period Suppression <a name=periodsuppression></a>
435409

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

0 commit comments

Comments
 (0)