diff --git a/README.md b/README.md
index 6c28c84..d54b7ff 100644
--- a/README.md
+++ b/README.md
@@ -28,5 +28,5 @@ cd [Path of source code folder]
bundle exec jekyll serve
```
6. Navigate to http://localhost:4000 in a browser.
-7. Add your own Markdown posts inside `_posts`.
+7. Add your own Markdown posts inside the `_posts` folder.
8. Profit!
diff --git a/_posts/2025-02-20-groff-apa.md b/_posts/2025-02-20-groff-apa.md
index 719b853..f632d61 100644
--- a/_posts/2025-02-20-groff-apa.md
+++ b/_posts/2025-02-20-groff-apa.md
@@ -8,7 +8,7 @@ permalink: /groff-apa
This guide explains why and how I used groff with the ms and refer macros to write my college essay in Neovim.
-# Table of Contents
+# 1. Table of Contents
1. [Table of Contents](/groff-apa#tableofcontents)
@@ -45,7 +45,7 @@ This guide explains why and how I used groff with the ms and refer macros to wri
11. [Conclusion](/groff-apa#conclusion)
-# Preface
+# 2. Preface
Many colleges give students a mandatory class where they learn how to cite and do referencing in essays.
@@ -59,7 +59,7 @@ I made a [Github repository](https://github.com/de-soot/groff-apa) as a companio
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.
-# Introduction
+# 3. Introduction
The [American Psychological Association](https://apa.org) (APA) 7th Edition [style guide](https://apastyle.apa.org) is the most popular for formatting references and citations in college-level essays (at least that was what my lecturer said when they gave out the writing assignment).
@@ -69,11 +69,11 @@ The [ms](https://www.gnu.org/software/groff/manual/groff.html.node/ms.html) ("ma
However, groff by itself cannot do citations and referencing out-of-the-box. Fortunately, it does come with a preprocessor called refer that does the citing and referencing for it. Although the defaults for refer do not conform to APA guidelines, it is not too complex to change those defaults to match any style guide as long as you know where to find the right things to change.
-# Prerequisites
+# 4. Prerequisites
This guide assumes you are using a Unix-based system (e.g. GNU/Linux, *BSD, macOS, etc.) and already know how to write and compile basic `groff ms` documents to Portable Document Format (PDF). If not, do not worry. There are many resources online for getting started, such as Luke Smith's videos on [groff](https://videos.lukesmith.xyz/w/eDqgKby1W4sHQGZgqZbMLe) and [refer](https://videos.lukesmith.xyz/w/5ANbTYv7cgF69FhpAkVBwi). For more detail, see GNU's official [manual](https://www.gnu.org/software/groff/manual/groff.html) or `troff`'s [HOWTO](https://troff.org/TheGroffFriendsHowto.pdf).
-# Cover Page
+# 5. Cover Page
My assignment did not require me to include a cover page, but yours might. By default, groff puts cover page information on the same page as the essay. Luckily, the ms macros contain a convenient way to change this. Just put [`.RP no`](https://linux.die.net/man/7/groff_ms) as the first line of your document (`.RP` stands for "report"; the `no` argument tells it to not repeat the cover page information on the next page):
@@ -83,7 +83,7 @@ My assignment did not require me to include a cover page, but yours might. By de
This is also needed for the next section on page numbering.
-# Page Numbering
+# 6. Page Numbering
The first page does not have any headers (including page numbering) because groff expects it to include cover page information (i.e. the title of the paper; optionally author(s), institution(s), date, and abstract).
@@ -110,7 +110,7 @@ The `.RP no` macro is needed for this, but it produces a cover page. Use PDF-edi
which works because even though the title (`.TL`) is required, it stops at the abstract (`.AB`, which ends at `.AE`; the `no` argument suppresses the "Abstract" heading).
-## Suppress Page Headers
+## 6.1 Suppress Page Headers
If instead you want to **not** have any page headers (including page numbering) for reasons such as plagerism report checkers potentially producing errors, disabling automatic page numbering is as easy as defining the central header to be empty:
@@ -118,15 +118,15 @@ If instead you want to **not** have any page headers (including page numbering)
.ds CH
```
-# Font
+# 7. Font
Many lecturers demand assignments to be submitted in double-spaced Times New Roman in 12 point size. This section covers how to change the font family, size, style, and line spacing.
-## Font Family
+## 7.1 Font Family
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.
-### Default Fonts
+### 7.1.1 Default Fonts
Changing to another one of the default fonts in groff is simple.
@@ -150,11 +150,11 @@ and (back to) serif font family:
There are many other default fonts in groff listed in [this post](https://technicallywewrite.com/2024/04/12/changefonts).
-### Custom Fonts
+### 7.1.2 Custom Fonts
Installing custom fonts for groff is a little bit trickier; I have not been able to get it to work on my device yet. I did find a [guide that seemed promising](https://www.port.de/cgi-bin/groff/AddingFonts) though. Maybe I will revisit this if I get it working in the future.
-## Font Size
+## 7.2 Font Size
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:
@@ -164,7 +164,7 @@ The default font size in groff is a little bit less than 12pt ([10pt](https://ww
As for what `PS` stands for, it probably means something like "Point Size"; `.nr` stands for "Number Registers".
-## Line Spacing
+## 7.3 Line Spacing
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`).
@@ -172,7 +172,7 @@ All parts of an APA-styled paper [should be double-spaced](https://apastyle.apa.
.nr VS 24
```
-## Font Style
+## 7.4 Font Style
Here is how to make your text **bold**,
@@ -192,13 +192,13 @@ And to set it back to normal:
.ft R \" Stands for Regular or Roman
```
-# In-text Citation
+# 8. In-text Citation
Now that everything is set up, we can start to get into the citations.
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.
-## Parenthetical Citation
+## 8.1 Parenthetical Citation
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:
@@ -215,17 +215,17 @@ join-authors " & " ", " " & " # Change default "and" to ampersand (&) when joini
.R2 \" Refer block end
```
-## Narrative Citation
+## 8.2 Narrative Citation
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.
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.
-# Reference List
+# 9. Reference List
This section is where we start to dive into refer's code (usually located inside either `/usr/share/groff/current/tmac` or `/usr/local/share/groff/current/tmac`). Rest assured, the changes that will be made will not be difficult as long as you know 3 things: what to change, what to change them to, and where to find them (all 3 being what I had to figure out on my own by reading and tinkering with the source code).
-## Formatting the Heading
+## 9.1 Formatting the Heading
The "References" heading is left-aligned by default, whereas [APA wants it centered](https://apastyle.apa.org/style-grammar-guidelines/paper-format/reference-list). Some extra changes not specified by APA my lecturer wanted were to make the Heading a little bigger and add an extra line of space below it.
@@ -259,7 +259,7 @@ Below is a list explaining each change made:
- (Optional) `.nr PS 14` above it increases the font size to 14pt, just remember to reset it back to normal (12pt) with `.nr PS 12` after.
- (Optional) `.sp 2` adds two extra lines of space below the heading.
-## Space Between Entries
+## 9.2 Space Between Entries
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.
@@ -280,7 +280,7 @@ Inside `refer-ms.tmac` on lines 44--45, you can find this:
{%comment%}
-### For Specific Entries
+### 9.2.1 For Specific Entries
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.
@@ -300,7 +300,7 @@ To fix an entry being split between pages, first identify the entry above it and
{%endcomment%}
-## Field Ordering
+## 9.3 Field Ordering
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.
@@ -336,7 +336,7 @@ Rearranging `D` (date) into the correct order (right after `A` (author(s)) and b
.ds ref*spec!4 Q A D T R G P I C O
```
-## Punctuation
+## 9.4 Punctuation
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.
@@ -421,7 +421,7 @@ The list below details the changes:
- All `\fP` in `arg 5` are moved to `arg 4` to make sure the punctuations after each field are not in bold or italics.
- When numbering pages, APA does not denote with `p.` for single pages or `pp.` for page ranges, so they were removed in their respective rows.
-### Period Suppression
+### 9.4.1 Period Suppression
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).
@@ -443,7 +443,7 @@ Now just remove the period (`.`) on the last line (213):
. as ref*string
```
-# Exporting as PDF
+# 10. Exporting as PDF
The plaintext document can be compiled with either `groff`,
@@ -466,7 +466,7 @@ Below is a list explaining what each of the optional arguments mean:
- `-R` selects refer macros.
- (Optional) `-dpaper=a4` and `-P-pa4` exports the paper to the international-standard A4 size instead of the default US letter.
-# Conclusion
+# 11. Conclusion
If you found this helpful in any way or have any questions, feel free to leave a comment below. Also read my [previous guide](/justify-text) on how I justify and hyphenate the text on this website.
diff --git a/_posts/2025-12-08-2s-complement.md b/_posts/2025-12-08-2s-complement.md
index 5a4aace..e8f04b3 100644
--- a/_posts/2025-12-08-2s-complement.md
+++ b/_posts/2025-12-08-2s-complement.md
@@ -21,8 +21,11 @@ If we flip all the bits of `x` using the bitwise NOT operator (`~`), we get a ne
We will call this new number `~x`, where `x + ~x = 2^n - 1`, since 2^n - 1 has all `n` number of bits set to `1`.
Rearranging the above equation for `x`, we get `x = (2^n - 1) - ~x`.
-It is then easy to find that `-x = -(2^n - 1 - ~x) = -2^n + 1 + ~x`.
-Now see the picture of where "flip the bits and add one" comes from.
+It is then easy to find that
+
+`-x = -(2^n - 1 - ~x) = -2^n + 1 + ~x`.
+
+Now start to see the picture of where "flip the bits and add one" comes from.
But we cannot just flip bits and add 1 to get `-x` with ordinary bits, that would just be `~x + 1`.
We are still missing the `-2^n` in the equation, but how would we get that?
@@ -36,3 +39,20 @@ When we flip the bits of `x`, this new bit we added will also get flipped along
Putting all the pieces together, we get that for a number `x` represented by `n` bits (with an extra bit having a place value of `-2^n`) where `x = (2^n - 1) - ~x`, you would need to flip its bits and add one to get `-2^n + ~x + 1 = -x`.
Hopefully after reading this, you will have gained a better understanding of using 2's complement for converting binary numbers to negative.
+
+
diff --git a/_site/README.md b/_site/README.md
index 6c28c84..d54b7ff 100644
--- a/_site/README.md
+++ b/_site/README.md
@@ -28,5 +28,5 @@ cd [Path of source code folder]
bundle exec jekyll serve
```
6. Navigate to http://localhost:4000 in a browser.
-7. Add your own Markdown posts inside `_posts`.
+7. Add your own Markdown posts inside the `_posts` folder.
8. Profit!
diff --git a/_site/feed.xml b/_site/feed.xml
index dfe9257..a11725e 100644
--- a/_site/feed.xml
+++ b/_site/feed.xml
@@ -1,4 +1,4 @@
-
But teachers generally just tell you to “flip the bits and add one” without really explaining why it works—similar to how high school teachers treat math formulas.
@@ -13,8 +13,11 @@ Since each bit can be0~x, where x + ~x = 2^n - 1, since 2^n - 1 has all n number of bits set to 1.
Rearranging the above equation for x, we get x = (2^n - 1) - ~x.
-It is then easy to find that -x = -(2^n - 1 - ~x) = -2^n + 1 + ~x.
-Now see the picture of where “flip the bits and add one” comes from.
-x = -(2^n - 1 - ~x) = -2^n + 1 + ~x.
Now start to see the picture of where “flip the bits and add one” comes from.
But we cannot just flip bits and add 1 to get -x with ordinary bits, that would just be ~x + 1.
We are still missing the -2^n in the equation, but how would we get that?
xPutting all the pieces together, we get that for a number x represented by n bits (with an extra bit having a place value of -2^n) where x = (2^n - 1) - ~x, you would need to flip its bits and add one to get -2^n + ~x + 1 = -x.
-Hopefully after reading this, you will have gained a better understanding of using 2’s complement for converting binary numbers to negative.
]]>Hopefully after reading this, you will have gained a better understanding of using 2’s complement for converting binary numbers to negative.
+ +]]>xConclusionMany colleges give students a mandatory class where they learn how to cite and do referencing in essays.
@@ -101,7 +107,7 @@ When we flip the bits ofxA 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.
-Introduction
+3. Introduction
The American Psychological Association (APA) 7th Edition style guide is the most popular for formatting references and citations in college-level essays (at least that was what my lecturer said when they gave out the writing assignment).
@@ -111,11 +117,11 @@ When we flip the bits of xHowever, groff by itself cannot do citations and referencing out-of-the-box. Fortunately, it does come with a preprocessor called refer that does the citing and referencing for it. Although the defaults for refer do not conform to APA guidelines, it is not too complex to change those defaults to match any style guide as long as you know where to find the right things to change.
-Prerequisites
+4. Prerequisites
This guide assumes you are using a Unix-based system (e.g. GNU/Linux, *BSD, macOS, etc.) and already know how to write and compile basic groff ms documents to Portable Document Format (PDF). If not, do not worry. There are many resources online for getting started, such as Luke Smith’s videos on groff and refer. For more detail, see GNU’s official manual or troff’s HOWTO.
-Cover Page
+5. Cover Page
My assignment did not require me to include a cover page, but yours might. By default, groff puts cover page information on the same page as the essay. Luckily, the ms macros contain a convenient way to change this. Just put .RP no as the first line of your document (.RP stands for “report”; the no argument tells it to not repeat the cover page information on the next page):
@@ -124,7 +130,7 @@ When we flip the bits of xThis is also needed for the next section on page numbering.
-Page Numbering
+6. Page Numbering
The first page does not have any headers (including page numbering) because groff expects it to include cover page information (i.e. the title of the paper; optionally author(s), institution(s), date, and abstract).
@@ -149,22 +155,22 @@ When we flip the bits of xwhich works because even though the title (.TL) is required, it stops at the abstract (.AB, which ends at .AE; the no argument suppresses the “Abstract” heading).
-Suppress Page Headers
+6.1 Suppress Page Headers
If instead you want to not have any page headers (including page numbering) for reasons such as plagerism report checkers potentially producing errors, disabling automatic page numbering is as easy as defining the central header to be empty:
.ds CH
-Font
+7. Font
Many lecturers demand assignments to be submitted in double-spaced Times New Roman in 12 point size. This section covers how to change the font family, size, style, and line spacing.
-Font Family
+7.1 Font Family
By default, groff already outputs text in your device’s default serif font family (typically Times New Roman), but sometimes (very rarely, in my experience) lecturers prefer sans-serif or even monospace in some cases.
-Default Fonts
+7.1.1 Default Fonts
Changing to another one of the default fonts in groff is simple.
@@ -185,11 +191,11 @@ When we flip the bits of xThere are many other default fonts in groff listed in this post.
-Custom Fonts
+7.1.2 Custom Fonts
Installing custom fonts for groff is a little bit trickier; I have not been able to get it to work on my device yet. I did find a guide that seemed promising though. Maybe I will revisit this if I get it working in the future.
-Font Size
+7.2 Font Size
The default font size in groff is a little bit less than 12pt (10pt, 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:
@@ -198,14 +204,14 @@ When we flip the bits of xAs for what PS stands for, it probably means something like “Point Size”; .nr stands for “Number Registers”.
-Line Spacing
+7.3 Line Spacing
All parts of an APA-styled paper should be double-spaced. By default, groff uses 120% of font size 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).
.nr VS 24
-Font Style
+7.4 Font Style
Here is how to make your text bold,
@@ -222,13 +228,13 @@ When we flip the bits of x.ft R \" Stands for Regular or Roman
-In-text Citation
+8. In-text Citation
Now that everything is set up, we can start to get into the citations.
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.
-Parenthetical Citation
+8.1 Parenthetical Citation
After some research, I found a blog post “no-tears” guide, 2 Github repositories, and a post from the GNU mailing list archive (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:
@@ -244,17 +250,17 @@ join-authors " & " ", " " & " # Change default "and" to ampersand (&
.R2 \" Refer block end
-Narrative Citation
+8.2 Narrative Citation
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.
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.
-Reference List
+9. Reference List
This section is where we start to dive into refer’s code (usually located inside either /usr/share/groff/current/tmac or /usr/local/share/groff/current/tmac). Rest assured, the changes that will be made will not be difficult as long as you know 3 things: what to change, what to change them to, and where to find them (all 3 being what I had to figure out on my own by reading and tinkering with the source code).
-Formatting the Heading
+9.1 Formatting the Heading
The “References” heading is left-aligned by default, whereas APA wants it centered. Some extra changes not specified by APA my lecturer wanted were to make the Heading a little bigger and add an extra line of space below it.
@@ -288,7 +294,7 @@ join-authors " & " ", " " & " # Change default "and" to ampersand (&
(Optional) .sp 2 adds two extra lines of space below the heading.
-Space Between Entries
+9.2 Space Between Entries
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) and maybe yours might too.
@@ -305,7 +311,7 @@ join-authors " & " ", " " & " # Change default "and" to ampersand (&
..
-Field Ordering
+9.3 Field Ordering
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.
@@ -338,7 +344,7 @@ join-authors " & " ", " " & " # Change default "and" to ampersand (&
.ds ref*spec!4 Q A D T R G P I C O
-Punctuation
+9.4 Punctuation
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.
@@ -422,7 +428,7 @@ join-authors " & " ", " " & " # Change default "and" to ampersand (&
When numbering pages, APA does not denote with p. for single pages or pp. for page ranges, so they were removed in their respective rows.
-Period Suppression
+9.4.1 Period Suppression
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.
@@ -442,7 +448,7 @@ join-authors " & " ", " " & " # Change default "and" to ampersand (&
. as ref*string
-Exporting as PDF
+10. Exporting as PDF
The plaintext document can be compiled with either groff,
@@ -465,7 +471,7 @@ join-authors " & " ", " " & " # Change default "and" to ampersand (&
(Optional) -dpaper=a4 and -P-pa4 exports the paper to the international-standard A4 size instead of the default US letter.
-Conclusion
+11. Conclusion
If you found this helpful in any way or have any questions, feel free to leave a comment below. Also read my previous guide on how I justify and hyphenate the text on this website.