From fba3fa71e1b95b84cdd70382902b90a35211ce5b Mon Sep 17 00:00:00 2001 From: Libby Baker Date: Wed, 15 Nov 2023 17:19:11 +0100 Subject: [PATCH 1/4] Moved all font definitions to bottom --- tueplots/fonts.py | 92 +++++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/tueplots/fonts.py b/tueplots/fonts.py index e812066..d3a7b0e 100644 --- a/tueplots/fonts.py +++ b/tueplots/fonts.py @@ -61,52 +61,6 @@ def cvpr2024(*, family="serif"): return _neurips_and_iclr_common(family=family) -def _neurips_and_iclr_common(*, family="serif"): - """Default fonts for Neurips.""" - return { - "text.usetex": False, - "font.serif": ["Times New Roman"], - "mathtext.fontset": "stix", # free ptmx replacement, for ICML and NeurIPS - "mathtext.rm": "Times New Roman", - "mathtext.it": "Times New Roman:italic", - "mathtext.bf": "Times New Roman:bold", - "font.family": family, - } - - -def _neurips_and_iclr_tex_common(*, family="serif"): - """Default fonts for Neurips. LaTeX version.""" - preamble = r"\renewcommand{\rmdefault}{ptm}\renewcommand{\sfdefault}{phv}" - if family == "serif": - return { - "text.usetex": True, - "font.family": "serif", - "text.latex.preamble": preamble, - } - preamble += ( - r"\renewcommand{\familydefault}{\sfdefault} \usepackage{sansmath} \sansmath" - ) - return { - "text.usetex": True, - "font.family": "sans-serif", - "text.latex.preamble": preamble, - } - - -def icml2022(*, family="serif"): - """Fonts for ICML 2022.""" - - return { - "text.usetex": False, - "font.serif": ["Times"], - "mathtext.fontset": "stix", # free ptmx replacement, for ICML and NeurIPS - "mathtext.rm": "Times", - "mathtext.it": "Times:italic", - "mathtext.bf": "Times:bold", - "font.family": family, - } - - def icml2022_tex(*, family="serif"): """Fonts for ICML 2022. LaTeX version.""" return _tex_times(family=family) @@ -142,6 +96,52 @@ def aaai2024_tex(*, family="serif"): return _tex_times(family=family) +def icml2022(*, family="serif"): + """Fonts for ICML 2022.""" + + return { + "text.usetex": False, + "font.serif": ["Times"], + "mathtext.fontset": "stix", # free ptmx replacement, for ICML and NeurIPS + "mathtext.rm": "Times", + "mathtext.it": "Times:italic", + "mathtext.bf": "Times:bold", + "font.family": family, + } + + +def _neurips_and_iclr_common(*, family="serif"): + """Default fonts for Neurips.""" + return { + "text.usetex": False, + "font.serif": ["Times New Roman"], + "mathtext.fontset": "stix", # free ptmx replacement, for ICML and NeurIPS + "mathtext.rm": "Times New Roman", + "mathtext.it": "Times New Roman:italic", + "mathtext.bf": "Times New Roman:bold", + "font.family": family, + } + + +def _neurips_and_iclr_tex_common(*, family="serif"): + """Default fonts for Neurips. LaTeX version.""" + preamble = r"\renewcommand{\rmdefault}{ptm}\renewcommand{\sfdefault}{phv}" + if family == "serif": + return { + "text.usetex": True, + "font.family": "serif", + "text.latex.preamble": preamble, + } + preamble += ( + r"\renewcommand{\familydefault}{\sfdefault} \usepackage{sansmath} \sansmath" + ) + return { + "text.usetex": True, + "font.family": "sans-serif", + "text.latex.preamble": preamble, + } + + def _tex_times(*, family): preamble = r"\usepackage{times} " if family == "serif": From 94f3bf849e542c9c6e2ca2012f1cf0991ea1680d Mon Sep 17 00:00:00 2001 From: Libby Baker Date: Mon, 20 Nov 2023 11:41:49 +0100 Subject: [PATCH 2/4] Renamed _neurips_and_iclr_common to _times_new_roman and corrected use cases --- tueplots/fonts.py | 146 +++++++++++++++++++++++++++------------------- 1 file changed, 86 insertions(+), 60 deletions(-) diff --git a/tueplots/fonts.py b/tueplots/fonts.py index d3a7b0e..995622b 100644 --- a/tueplots/fonts.py +++ b/tueplots/fonts.py @@ -3,102 +3,151 @@ def neurips2021(*, family="serif"): """Fonts for Neurips 2021.""" - return _neurips_and_iclr_common(family=family) + # NeurIPS' style-files states that it uses Times New Roman + # font, but includes the 'ptm' package, which implements + # the 'Times' font. + # Therefore, refer to 'Times' instead of 'Times New Roman' + return _times(family=family) def neurips2021_tex(*, family="serif"): """Fonts for Neurips 2021. LaTeX version.""" - return _neurips_and_iclr_tex_common(family=family) + return _times_tex_via_pkg_ptm(family=family) def neurips2022(*, family="serif"): """Fonts for Neurips 2022.""" - return _neurips_and_iclr_common(family=family) + # NeurIPS' style-files states that it uses Times New Roman + # font, but includes the 'ptm' package, which implements + # the 'Times' font. + # Therefore, refer to 'Times' instead of 'Times New Roman' + return _times(family=family) def neurips2022_tex(*, family="serif"): """Fonts for Neurips 2022. LaTeX version.""" - return _neurips_and_iclr_tex_common(family=family) + return _times_tex_via_pkg_ptm(family=family) def neurips2023(*, family="serif"): """Fonts for Neurips 2023.""" - return _neurips_and_iclr_common(family=family) + # NeurIPS' style-files states that it uses Times New Roman + # font, but includes the 'ptm' package, which implements + # the 'Times' font. + # Therefore, refer to 'Times' instead of 'Times New Roman' + return _times(family=family) def neurips2023_tex(*, family="serif"): """Fonts for Neurips 2023. LaTeX version.""" - return _neurips_and_iclr_tex_common(family=family) + return _times_tex_via_pkg_ptm(family=family) def iclr2023_tex(*, family="serif"): """Fonts for ICLR 2023. LaTeX version.""" - return _neurips_and_iclr_tex_common(family=family) + return _times_tex_via_pkg_times(family=family) def iclr2024_tex(*, family="serif"): """Fonts for ICLR 2024. LaTeX version.""" - return _neurips_and_iclr_tex_common(family=family) + return _times_tex_via_pkg_times(family=family) def iclr2023(*, family="serif"): """Fonts for ICLR 2023. LaTeX version.""" - return _neurips_and_iclr_common(family=family) + return _times(family=family) def iclr2024(*, family="serif"): """Fonts for ICLR 2024. LaTeX version.""" - return _neurips_and_iclr_common(family=family) + return _times(family=family) def cvpr2024_tex(*, family="serif"): """Fonts for CVPR 2024. LaTeX version.""" - return _neurips_and_iclr_tex_common(family=family) + return _times_tex_via_pkg_ptm(family=family) def cvpr2024(*, family="serif"): """Fonts for CVPR 2024. LaTeX version.""" - return _neurips_and_iclr_common(family=family) + return _times(family=family) def icml2022_tex(*, family="serif"): """Fonts for ICML 2022. LaTeX version.""" - return _tex_times(family=family) + return _times_tex_via_pkg_times(family=family) def jmlr2001_tex(*, family="serif"): """Fonts for JMLR. LaTeX version.""" - return _tex_computer_modern(family=family) + return _computer_modern_tex(family=family) def tmlr2023_tex(*, family="serif"): """Fonts for TMLR. LaTeX version.""" - return _tex_computer_modern(family=family) + return _computer_modern_tex(family=family) def aistats2022_tex(*, family="serif"): """Fonts for AISTATS 2022. LaTeX version.""" - return _tex_computer_modern(family=family) + return _computer_modern_tex(family=family) def aistats2023_tex(*, family="serif"): """Fonts for AISTATS 2023. LaTeX version.""" - return _tex_times(family=family) + return _times_tex_via_pkg_times(family=family) def uai2023_tex(*, family="serif"): """Fonts for UAI 2023. LaTeX version.""" - return _tex_times(family=family) + return _times_tex_via_pkg_times(family=family) def aaai2024_tex(*, family="serif"): """Fonts for AAAI 2024. LaTeX version.""" - return _tex_times(family=family) + return _times_tex_via_pkg_times(family=family) def icml2022(*, family="serif"): """Fonts for ICML 2022.""" + return _times(family=family) + +def beamer_moml(): + """Fonts that are compatible with the beamer template of the method-of-machine-learning group in Tübingen.""" + return { + "text.usetex": False, + "mathtext.fontset": "custom", + "mathtext.it": "sans:italic", + "font.sans-serif": ["Roboto Condensed"], + "font.family": "sans-serif", + "font.weight": "light", + "axes.labelweight": "light", + "axes.titleweight": "light", + } + + +def beamer_moml_dark_bg(): + """Fonts for :func:`beamer_moml` with dark background.""" + return { + "text.usetex": False, + "font.serif": ["Roboto Condensed"], + "font.family": "serif", + "font.weight": "light", + "axes.labelweight": "light", + "axes.titleweight": "light", + } + + +# Helper functions below + + +def _times(*, family="serif"): + """Times font. + + Used, e.g., for ICML 2022. + """ + # todo: remove default family. return { "text.usetex": False, "font.serif": ["Times"], @@ -110,21 +159,24 @@ def icml2022(*, family="serif"): } -def _neurips_and_iclr_common(*, family="serif"): - """Default fonts for Neurips.""" - return { - "text.usetex": False, - "font.serif": ["Times New Roman"], - "mathtext.fontset": "stix", # free ptmx replacement, for ICML and NeurIPS - "mathtext.rm": "Times New Roman", - "mathtext.it": "Times New Roman:italic", - "mathtext.bf": "Times New Roman:bold", - "font.family": family, - } +# def _times_new_roman(*, family="serif"): +# """Default fonts for Neurips.""" +# return { +# "text.usetex": False, +# "font.serif": ["Times New Roman"], +# "mathtext.fontset": "stix", # free ptmx replacement, for ICML and NeurIPS +# "mathtext.rm": "Times New Roman", +# "mathtext.it": "Times New Roman:italic", +# "mathtext.bf": "Times New Roman:bold", +# "font.family": family, +# } -def _neurips_and_iclr_tex_common(*, family="serif"): - """Default fonts for Neurips. LaTeX version.""" +def _times_tex_via_pkg_ptm(*, family): + """Times font, implemented in Latex via the ptm-package. + + Default fonts for Neurips. + """ preamble = r"\renewcommand{\rmdefault}{ptm}\renewcommand{\sfdefault}{phv}" if family == "serif": return { @@ -142,7 +194,7 @@ def _neurips_and_iclr_tex_common(*, family="serif"): } -def _tex_times(*, family): +def _times_tex_via_pkg_times(*, family): preamble = r"\usepackage{times} " if family == "serif": return { @@ -160,7 +212,7 @@ def _tex_times(*, family): } -def _tex_computer_modern(*, family): +def _computer_modern_tex(*, family): if family == "serif": return { "text.usetex": True, @@ -175,29 +227,3 @@ def _tex_computer_modern(*, family): "font.family": "sans-serif", "text.latex.preamble": preamble, } - - -def beamer_moml(): - """Fonts that are compatible with the beamer template of the method-of-machine-learning group in Tübingen.""" - return { - "text.usetex": False, - "mathtext.fontset": "custom", - "mathtext.it": "sans:italic", - "font.sans-serif": ["Roboto Condensed"], - "font.family": "sans-serif", - "font.weight": "light", - "axes.labelweight": "light", - "axes.titleweight": "light", - } - - -def beamer_moml_dark_bg(): - """Fonts for :func:`beamer_moml` with dark background.""" - return { - "text.usetex": False, - "font.serif": ["Roboto Condensed"], - "font.family": "serif", - "font.weight": "light", - "axes.labelweight": "light", - "axes.titleweight": "light", - } From 43f14721d9d8f5d953b224c5de48aaae66d563c4 Mon Sep 17 00:00:00 2001 From: Libby Baker Date: Mon, 20 Nov 2023 12:00:29 +0100 Subject: [PATCH 3/4] Removed todo --- tueplots/fonts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tueplots/fonts.py b/tueplots/fonts.py index 995622b..dd21dea 100644 --- a/tueplots/fonts.py +++ b/tueplots/fonts.py @@ -147,7 +147,7 @@ def _times(*, family="serif"): Used, e.g., for ICML 2022. """ - # todo: remove default family. + return { "text.usetex": False, "font.serif": ["Times"], From b9083303cd829f855d7eb4bd44df96646d880302 Mon Sep 17 00:00:00 2001 From: Libby Baker Date: Mon, 20 Nov 2023 13:06:34 +0100 Subject: [PATCH 4/4] Removed times new roman (not used by any of the current conferences/journals) --- tueplots/fonts.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tueplots/fonts.py b/tueplots/fonts.py index dd21dea..770cb4c 100644 --- a/tueplots/fonts.py +++ b/tueplots/fonts.py @@ -159,19 +159,6 @@ def _times(*, family="serif"): } -# def _times_new_roman(*, family="serif"): -# """Default fonts for Neurips.""" -# return { -# "text.usetex": False, -# "font.serif": ["Times New Roman"], -# "mathtext.fontset": "stix", # free ptmx replacement, for ICML and NeurIPS -# "mathtext.rm": "Times New Roman", -# "mathtext.it": "Times New Roman:italic", -# "mathtext.bf": "Times New Roman:bold", -# "font.family": family, -# } - - def _times_tex_via_pkg_ptm(*, family): """Times font, implemented in Latex via the ptm-package.