Org Mode: a LaTeX letter that includes PDFs and hyperlinked page numbers
| org
I messed up on one of my tax forms, so I needed to
send the tax agency a single document that
included the amended tax return and the supporting
slips, with my name, social insurance number, and
reference number on every page. It turned out to
be rather complicated trying to get calculated
\pageref
to work with \includepdf
, so I just
used \hyperlink
with hard-coded page numbers. I
also needed to use qpdf --decrypt input.pdf
output.pdf
to decrypt a PDF I downloaded from one
of my banks before I could include it with
\includepdf
.
Here's what I wanted to do with this Org Mode / LaTeX example:
- Coloured header on all pages with info and page numbers
- Including PDFs
- Hyperlinks to specific pages
* Letter
#+DATE: 2025-09-24
Text of the letter goes here.
Please find attached:
| Pages | |
| @@latex:\pages{2}{10}@@ | Description of filename1.pdf |
| @@latex:\hyperlink{page.5}{5}@@ | Can link to a specific page |
| @@latex:\pages{11}{15}@@ | Description of filename2.pdf |
After filling it in, I exported it with C-c C-e
(org-export
) C-s
(to limit it to the subtree)
l p
(to export a PDF via LaTeX).
Not the end of the world. At least I learned a little more LaTeX and Org Mode along the way!