1

I took some templates/macros that use \Large/\small... to configure the font size of my title page. The problem is that when I change the font size of the rest of the document using \documentclass[12pt]{memoir} instead of \documentclass[10pt]{memoir}, then the font size of the title template is increased, breaking the layout.

I tried to use \fontsize{10}{12}\selectfont to force a smaller font for the page title, but the problem is that it does not reduce the font size of \Large/\small… They are still Large/small compared to the document 12pt instead of the current 10pt.

How can I simply change locally the font size in such a way that \Large, \small… size is updated to match the new local font size?

enter image description here

MWE:

\documentclass[a4paper,12pt]{memoir}

\begin{document}

\section{Simple text}

\noindent Hello\ {\small Hello $\leftarrow $ This one is smaller than previous line as expected}

\section{``Small'' text}

{\fontsize{10}{12}\selectfont \noindent Hello\ {\small Hello $\leftarrow $ I expect this one to be smaller than previous line\dots and its bigger}}

\end{document}

EDIT

Concerning the solution proposed in the comment, \relsize{} looks great for new text, but it won't actually change the macros \Large, \tiny… So this solution won't apply when I want to convert an existing document (tikz picture, pre-made template...). Also, using stuff like \Large allow people to use consistent sizes across the whole document: it would be quite easy to have many different \relsize{...} in a same document if one is not very cautious.

I tried the solution proposed by @muzimuzhi in the comments. It works very well on page title (it does reset the layout in page title indeed... but not sure why when I put it on a new page but not inside a page title it does not change the layout), but it does not work great when used inside an existing text. It adds a huge space (and can push the text in the margin), as highlighted in red:

enter image description here

MWE:

\documentclass[a4paper,12pt]{memoir}
\usepackage{lipsum}
\begin{document}

\section{Simple text}

\noindent Hello\ {\small Hello $\leftarrow $ This one is smaller than previous line as expected}

\lipsum[1]

\section{``Small'' text}

Text before: see the space (it even goes into the margin) {\makeatletter\let\newcommand\renewcommand\input{size10.clo} Hello\ {\small Hello $\leftarrow $ I expect this one to be smaller than previous line\dots and it does work now!}} Text after.

\end{document}

tobiasBora
  • 8,684
  • 1
    \large etc will adapt to the documentclass option already so that would be the standard answer: using \fontsize{10}{12} is to explictly not following the documentclass option. for full control over font sizes and text widths you can test if the size options are used and specify a size in each case – David Carlisle Jun 14 '21 at 19:46
  • 2
    Maybe a look at the relsize package is interesting for you (you could, instead of using \Larger, etc. use \relscale{1.2} to make the current font 20% larger than the current size). – Skillmon Jun 14 '21 at 19:59
  • 2
    Instead of \fontsize{10}{12}\selectfont, you can reload the corresponding font-size config file size10.clo. Note it not only changes commands like \large, but also lengths for page geometry or spacing. All the changes will be local. – muzimuzhi Z Jun 14 '21 at 20:19
  • @muzimuzhiZ Thanks a lot, it works great in page title (I used this answer for the syntax [1]). However, as you pointed out, it does change the page geometry in my title page... but not always: when I put {\makeatletter\let\newcommand\renewcommand\input{size10.clo} my text} outside of the page title it seems that the geometry is not changed: any idea why? Also, when used inside an existing text, it adds a huge space before (see my edit). Any idea how to make it work also for inline texts?

    [1] https://tex.stackexchange.com/questions/15835/switching-to-different-font-sizes-locally

    – tobiasBora Jun 15 '21 at 07:59
  • @Skillmon Thanks. It is nice to use for new texts, however it has three issues: first it wont change \Large in existing macros/templates, then \Large is not always proportional to the normal font size: for instance in memoir, in 10pt normal size, Large is 1.4 larger, but in 12pt, Large is 1.54 larger so we can't define a single value for \relscale. Also, it is easier to have many values of \relscale in a document, and it will likely break consistency (even if this last issue can be mitigated by defining macros fixing the scale). https://www.sascha-frank.com/latex-font-size.html – tobiasBora Jun 15 '21 at 08:06
  • @DavidCarlisle You mean like redefining the \Large macros working for the new size? It sounds like a lot of work, especially when there are many different cases (for instance the memoir class has 12*12=144 values to configure https://www.sascha-frank.com/latex-font-size.html) There is no package that does that for me already? – tobiasBora Jun 15 '21 at 08:11
  • @tobiasBora no I meant the intention (even if it doesn't work well in your case) is that you simply use \Large and the class will have defined that to be a suitable size based on the global size option. – David Carlisle Jun 15 '21 at 08:34
  • Ah the size10.clo assumes it will be included in vertical mode, in which the space tokens converted from non-consecutive newlines are all ignored. But in your case size10.clo is included in horizontal mode, hence all the space characters take effect. Perhaps you have to copy-and-paste the font-size macros from size10.clo ... This is even less recommended. – muzimuzhi Z Jun 15 '21 at 10:14
  • 1
    Also, using stuff like \Large allow people to use consistent sizes across the whole document: But you you seem to be asking for a solution which changes these macros in ways which make them inconsistent. So what would count as a satisfactory solution? – cfr Mar 29 '24 at 04:19
  • @cfr I'm not saying the default behavior is bad, it's a bit like the difference between absolute vs relative. \Large provides an absolute font size, and I wanted to make it relative to the current font size in use, which makes sense in some cases (if I decide that my text should be slightly smaller, e.g. for a picture, while keeping the same ratio between small text and large text as in the main document). Just like css also provides the em unit to refer to the font size of tge parent container. – tobiasBora Mar 29 '24 at 09:08
  • @cfr and yes, in my comment above the "consistent" refers to the fact that it is easy to create multiple close but slightly different \relsize{1.12}, \relsize{1.13} in differents parts of the document since it is a continuous functior… (and i might be too lazy to check the value I used in previous pictures or just forget I used it) while a relative \large, with discrete and predefined jumps makes it easier to always use the same value without worrying if I used 1.12 before or 1.13. – tobiasBora Mar 29 '24 at 09:17

1 Answers1

2

You can easily change the font size using the fontscale package. (Full disclosure: I am the package author.)

I show how to change the font size commands from \tiny to \normalsize to \Huge mid-document. Note that you typically only need to set the font sizes once in the preamble. This is just for demonstration.

\documentclass{article}
\usepackage{fontscale}
\usepackage{parskip,stix2}%looks nicer

\begin{document}

Package defaults: \smallskip

\PrintSampleText[\PrintFontSizeCommand: \CurrentFontSize]

\bigskip Set font sizes using a musical scale: \smallskip

\fontscalesetup{musical,normalsize/size=10bp}

\PrintSampleText[\PrintFontSizeCommand: \CurrentFontSize]

\newpage Set arbitrary font sizes: \smallskip

\fontscalesetup { tiny=5, scriptsize=6, footnotesize=7, small=8, normalsize=9, large=10, Large=11, LARGE=12, huge=14, Huge=16 }

\PrintSampleText[\PrintFontSizeCommand: \CurrentFontSize]

\end{document}

User23456234
  • 1,808