fix(cv-template): compile main_example.tex on apt-packaged moderncv (#242) (#323)

Routes name styling through \namefont (present on every moderncv version) and
hands hyperref to the class via \AtEndPreamble, fixing both 2.3.1 compile
failures; pdfpagemode pinned to UseNone so the hook move cannot flip viewer
behavior. Diagnosis and fix design by camcro0607 (#242); verified on real
Debian bookworm apt moderncv 2.3.1 by ayobamiseun; modern-toolchain and PDF
catalog verification on 2.5.1 at review time.

Co-authored-by: camcro0607 <172529990+camcro0607@users.noreply.github.com>
This commit is contained in:
Oscar Madera
2026-08-15 21:31:41 +02:00
committed by GitHub
co-authored by camcro0607
parent 2ea29b09b9
commit c696b60b77
3 changed files with 63 additions and 20 deletions
@@ -1,5 +1,5 @@
--- ---
framework_version: 1.4.0 framework_version: 1.4.1
--- ---
# CV Templates and Tailoring Guide # CV Templates and Tailoring Guide
@@ -29,28 +29,42 @@ Expected output: `Output written on main_<company>_<role>.pdf (2 pages, ...)`. A
\moderncvstyle{banking} \moderncvstyle{banking}
\moderncvcolor{blue} \moderncvcolor{blue}
% Force both first and last name AND section headings to render in moderncv % Force the name and section headings to render in moderncv blue (color1).
% blue (color1). Default banking on lualatex+MiKTeX leaves these black, which % Default banking leaves them black: moderncvstylebanking.sty's \colorlet
% looks inconsistent with the rest of the blue accent scheme. % copies (not aliases) the pre-scheme accent colour, so the name colours are
\renewcommand*{\firstnamestyle}[1]{{\fontsize{34}{36}\bfseries\upshape\color{color1}#1}} % frozen before \moderncvcolor runs. Re-let them after. \namefont is the hook
\renewcommand*{\lastnamestyle}[1]{{\fontsize{34}{36}\bfseries\upshape\color{color1}#1}} % every name-style macro routes through, so this also works on moderncv 2.3.1
% (Debian/Ubuntu apt), which has no \firstnamestyle/\lastnamestyle at all.
\renewcommand*{\namefont}{\fontsize{34}{36}\bfseries\upshape}
\colorlet{firstnamecolor}{color1}
\colorlet{lastnamecolor}{color1}
\colorlet{namecolor}{color1}
\renewcommand*{\sectionstyle}[1]{{\sectionfont\color{color1}#1}} \renewcommand*{\sectionstyle}[1]{{\sectionfont\color{color1}#1}}
\usepackage[utf8]{inputenc} \usepackage[utf8]{inputenc}
\usepackage{hyperref} % moderncv loads hyperref itself in an \AtEndPreamble hook, so \hypersetup
\hypersetup{ % must go in an \AtEndPreamble of our own: on moderncv < 2.4 a top-level
% \usepackage{hyperref} clashes with the class's own
% \RequirePackage[unicode]{hyperref}. From 2.4.0 the class passes its options
% through \PassOptionsToPackage instead, which is what removes that clash.
\AtEndPreamble{\hypersetup{
colorlinks=true, colorlinks=true,
linkcolor=blue, linkcolor=blue,
filecolor=magenta, filecolor=magenta,
urlcolor=blue, urlcolor=blue,
pdftitle={[YOUR_NAME] - CV}, pdftitle={[YOUR_NAME] - CV},
pdfpagemode=FullScreen, % Keep pdfpagemode=UseNone: this block runs after moderncv's own
} % \AtEndPreamble (moderncv.cls sets pdfpagemode there), so a FullScreen
% value here would win and open every CV in fullscreen presentation mode.
pdfpagemode=UseNone,
}}
\usepackage[scale=0.77]{geometry} \usepackage[scale=0.77]{geometry}
\usepackage{import} \usepackage{import}
% Personal data % Personal data
\name{[FIRST_NAME]}{[LAST_NAME]} \name{[FIRST_NAME]}{[LAST_NAME]}
% If you have no address to list, DELETE this whole line. \address{}{}{} fails
% with "There's no line here to end" on every moderncv version.
\address{[YOUR_ADDRESS]}{}{} \address{[YOUR_ADDRESS]}{}{}
\phone[mobile]{[YOUR_PHONE]} \phone[mobile]{[YOUR_PHONE]}
\email{[YOUR_EMAIL]} \email{[YOUR_EMAIL]}
@@ -72,7 +86,7 @@ Expected output: `Output written on main_<company>_<role>.pdf (2 pages, ...)`. A
### Color overrides ### Color overrides
The three `\renewcommand*` lines in the preamble are required on lualatex+MiKTeX. Without them the firstname, lastname, and section headings render in black even though `\moderncvcolor{blue}` is set, which looks inconsistent with the rest of the blue accent scheme (links, bullet markers, contact icons). The override forces all three to use `color1` (moderncv's accent colour, which becomes blue under `\moderncvcolor{blue}`). Both names render bold; if you prefer the firstname in regular weight, change the firstnamestyle override from `\bfseries` to `\mdseries`. Don't drop the override - on most modern installs the defaults render visibly wrong. The `\renewcommand*` on `\namefont` and the three `\colorlet` lines in the preamble are required on lualatex+MiKTeX. Without them the name and section headings render in black even though `\moderncvcolor{blue}` is set, which looks inconsistent with the rest of the blue accent scheme (links, bullet markers, contact icons). The cause: `moderncvstylebanking.sty` defines the name colours with `\colorlet`, which *copies* the accent colour as it is before the scheme is applied, so the name colours are frozen to the pre-scheme value; re-assigning them with `\colorlet` after `\moderncvcolor{blue}` (as the preamble does) re-pins them to `color1`. `\namefont` is the shared hook every name-style macro routes through, so the block is version-agnostic - including moderncv 2.3.1 from Debian/Ubuntu apt, which has no `\firstnamestyle`/`\lastnamestyle` at all. Both names render bold; if you prefer regular weight, change `\bfseries` to `\mdseries` in the `\namefont` line (the weight now lives there, so it applies to the whole name). Don't drop the overrides - on most modern installs the defaults render visibly wrong.
### Spacing inside itemize lists (important) ### Spacing inside itemize lists (important)
+15
View File
@@ -33,6 +33,21 @@ per-file diff commands.
between (e.g. `60.000,50`, `108,5`) keep parsing exactly as before. Pinned by between (e.g. `60.000,50`, `108,5`) keep parsing exactly as before. Pinned by
`tests/test_convert_salary_excel.py`. `tests/test_convert_salary_excel.py`.
- **`main_example.tex` compiles on apt-packaged moderncv** (#242) - the banking template
set its name styling through `\firstnamestyle`/`\lastnamestyle`, which moderncv 2.3.1
(Debian/Ubuntu apt) does not have, so a fresh fork could not compile its own example CV
on that toolchain. Name styling now routes through `\namefont`, the hook every name-style
macro shares: a true no-op on moderncv 2.4+ (where head iii typesets via
`\firstnamestyle`/`\lastnamestyle` and never calls `\namefont`'s replacements), and the
only option on 2.3.1 where those macros do not exist. Two review follow-ups landed in the
same change: the `\hypersetup` comment now names the real clash mechanism
(`\RequirePackage[unicode]{hyperref}` on < 2.4; `\PassOptionsToPackage`, introduced in
2.4.0, is what removes the clash), and the metadata block sets `pdfpagemode=UseNone` - a
`FullScreen` value there would win over the class's own `\AtEndPreamble` default and make
every CV open in fullscreen presentation mode. `05-cv-templates.md`'s preamble copy stays
in lockstep (framework_version 1.4.0 -> 1.4.1). Verified on moderncv 2.5.1: exit 0,
exactly 2 pages, rendering unchanged.
## [1.5.0] - 2026-08-12 ## [1.5.0] - 2026-08-12
### Added ### Added
+23 -9
View File
@@ -10,28 +10,42 @@
\moderncvstyle{banking} \moderncvstyle{banking}
\moderncvcolor{blue} \moderncvcolor{blue}
% Force both first and last name AND section headings to render in moderncv % Force the name and section headings to render in moderncv blue (color1).
% blue (color1). Default banking on lualatex+MiKTeX leaves these black, which % Default banking leaves them black: moderncvstylebanking.sty's \colorlet
% looks inconsistent with the rest of the blue accent scheme. % copies (not aliases) the pre-scheme accent colour, so the name colours are
\renewcommand*{\firstnamestyle}[1]{{\fontsize{34}{36}\bfseries\upshape\color{color1}#1}} % frozen before \moderncvcolor runs. Re-let them after. \namefont is the hook
\renewcommand*{\lastnamestyle}[1]{{\fontsize{34}{36}\bfseries\upshape\color{color1}#1}} % every name-style macro routes through, so this also works on moderncv 2.3.1
% (Debian/Ubuntu apt), which has no \firstnamestyle/\lastnamestyle at all.
\renewcommand*{\namefont}{\fontsize{34}{36}\bfseries\upshape}
\colorlet{firstnamecolor}{color1}
\colorlet{lastnamecolor}{color1}
\colorlet{namecolor}{color1}
\renewcommand*{\sectionstyle}[1]{{\sectionfont\color{color1}#1}} \renewcommand*{\sectionstyle}[1]{{\sectionfont\color{color1}#1}}
\usepackage[utf8]{inputenc} \usepackage[utf8]{inputenc}
\usepackage{hyperref} % moderncv loads hyperref itself in an \AtEndPreamble hook, so \hypersetup
\hypersetup{ % must go in an \AtEndPreamble of our own: on moderncv < 2.4 a top-level
% \usepackage{hyperref} clashes with the class's own
% \RequirePackage[unicode]{hyperref}. From 2.4.0 the class passes its options
% through \PassOptionsToPackage instead, which is what removes that clash.
\AtEndPreamble{\hypersetup{
colorlinks=true, colorlinks=true,
linkcolor=blue, linkcolor=blue,
filecolor=magenta, filecolor=magenta,
urlcolor=blue, urlcolor=blue,
pdftitle={[YOUR_NAME] - CV}, pdftitle={[YOUR_NAME] - CV},
pdfpagemode=FullScreen, % Keep pdfpagemode=UseNone: this block runs after moderncv's own
} % \AtEndPreamble (moderncv.cls sets pdfpagemode there), so a FullScreen
% value here would win and open every CV in fullscreen presentation mode.
pdfpagemode=UseNone,
}}
\usepackage[scale=0.80]{geometry} \usepackage[scale=0.80]{geometry}
\usepackage{import} \usepackage{import}
% personal data % personal data
\name{[First]}{[Last]} \name{[First]}{[Last]}
% If you have no address to list, DELETE this whole line. \address{}{}{} fails
% with "There's no line here to end" on every moderncv version.
\address{[Your Address, City, Country]}{}{} \address{[Your Address, City, Country]}{}{}
\phone[mobile]{[+XX XXXXXXXXXX]} \phone[mobile]{[+XX XXXXXXXXXX]}
\email{[your.email@example.com]} \email{[your.email@example.com]}