4

actual problem:

How to make a second font the same "actual" size of the first one.

\documentclass[a4paper, 12pt]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}
\usepackage{amsmath}

\newcommand*{\afont}{\fontsize{14}{48}\itshape\fontfamily{qzc}\selectfont}
\DeclareTextFontCommand{\texta}{\afont}
\newcommand*{\bfont}{\fontsize{21}{48}\itshape\fontfamily{qzc}\selectfont}
\DeclareTextFontCommand{\textb}{\bfont}
\newcommand*{\cfont}{\fontsize{30}{48}\itshape\fontfamily{qzc}\selectfont}
\DeclareTextFontCommand{\textc}{\cfont}

\newcommand{\printa}[1]{\texta{#1}}
\newcommand{\printb}[1]{\textb{#1}}
\newcommand{\printc}[1]{\textc{#1}}

\DeclareMathOperator{\matha}{\printa{SPEZIAL}}
\DeclareMathOperator{\mathb}{\printb{SPEZIAL}}
\DeclareMathOperator{\mathc}{\printc{SPEZIAL}}
\DeclareMathOperator{\mathd}{\printd{SPEZIAL}}

\begin{document}
\chapter{Test}
This Is A Great Sentence With A $\matha$ Word.\\
{\Large This Is A Great Sentence With A $\mathb$ Word.}\\
{\Huge This Is A Great Sentence With A $\mathc$ Word.}\\
\\
SPEZIAL=14 rest=12 difference=2\\
SPEZIAL=21 rest=17 difference=4\\
SPEZIAL=30 rest=25 difference=5
\end{document}

Is there a way to define normalsize, large, Large, ... of the second font to fit to the rest of the text?


I'm using two different fonts in one document.

Short form:

\documentclass[a4paper, 12pt]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}
\usepackage{amsmath}

\newcommand*{\myfont}{\itshape\fontfamily{qzc}\selectfont}
\DeclareTextFontCommand{\textmy}{\myfont}

\newcommand{\printmy}[1]{\textmy{#1}}

\DeclareMathOperator{\mathmy}{\printmy{SPEZIAL}}

\begin{document}
\chapter{Test}
This Is A Great Sentence With A $\mathmy$ Word.\\
This Is A Great Sentence With A {\large $\mathmy$} Word.\\ %bad fix
{\large This Is A Great Sentence With A $\mathmy$ Word.}
\end{document}

The SPEZIAL word doesn't use the right size.


Long form:

Here a (not really) MWE, but a test document with different sizes.

\documentclass[a4paper, 12pt]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}
\usepackage{amsmath}

\newcommand*{\nofont}{\itshape\fontfamily{qzc}\selectfont}
\DeclareTextFontCommand{\textno}{\nofont}
\newcommand*{\largefont}{\large\itshape\fontfamily{qzc}\selectfont}
\DeclareTextFontCommand{\textlarge}{\largefont}
\newcommand*{\afont}{\fontsize{12}{90}\itshape\fontfamily{qzc}\selectfont}
\DeclareTextFontCommand{\texta}{\afont}
\newcommand*{\bfont}{\fontsize{12}{1}\itshape\fontfamily{qzc}\selectfont}
\DeclareTextFontCommand{\textb}{\bfont}
\newcommand*{\cfont}{\fontsize{12}{200}\itshape\fontfamily{qzc}\selectfont}
\DeclareTextFontCommand{\textc}{\cfont}
\newcommand*{\dfont}{\fontsize{12}{48}\itshape\fontfamily{qzc}\selectfont}
\DeclareTextFontCommand{\textd}{\dfont}
\newcommand*{\efont}{\fontsize{13}{48}\itshape\fontfamily{qzc}\selectfont}
\DeclareTextFontCommand{\texte}{\efont}
\newcommand*{\ffont}{\fontsize{14}{48}\itshape\fontfamily{qzc}\selectfont}
\DeclareTextFontCommand{\textf}{\ffont}
\newcommand*{\gfont}{\fontsize{15}{48}\itshape\fontfamily{qzc}\selectfont}
\DeclareTextFontCommand{\textg}{\gfont}
\newcommand*{\hfont}{\fontsize{16}{48}\itshape\fontfamily{qzc}\selectfont}
\DeclareTextFontCommand{\texth}{\hfont}

\newcommand{\printno}[1]{\textno{#1}}
\newcommand{\printlarge}[1]{\textlarge{#1}}
\newcommand{\printa}[1]{\texta{#1}}
\newcommand{\printb}[1]{\textb{#1}}
\newcommand{\printc}[1]{\textc{#1}}
\newcommand{\printd}[1]{\textd{#1}}
\newcommand{\printe}[1]{\texte{#1}}
\newcommand{\printf}[1]{\textf{#1}}
\newcommand{\printg}[1]{\textg{#1}}
\newcommand{\printh}[1]{\texth{#1}}

\DeclareMathOperator{\mathno}{\printno{SPEZIAL}}
\DeclareMathOperator{\mathlarge}{\printlarge{SPEZIAL}}
\DeclareMathOperator{\matha}{\printa{SPEZIAL}}
\DeclareMathOperator{\mathb}{\printb{SPEZIAL}}
\DeclareMathOperator{\mathc}{\printc{SPEZIAL}}
\DeclareMathOperator{\mathd}{\printd{SPEZIAL}}
\DeclareMathOperator{\mathe}{\printe{SPEZIAL}}
\DeclareMathOperator{\mathf}{\printf{SPEZIAL}}
\DeclareMathOperator{\mathg}{\printg{SPEZIAL}}
\DeclareMathOperator{\mathh}{\printh{SPEZIAL}}

\begin{document}
\chapter{Test}
This Is A Great Sentence With A $\mathno$ Word.

This Is A Great Sentence With A $\mathlarge$ Word. I guess this is the right size.

{\large This Is A Great Sentence With A $\mathlarge$ Word. Doesn't grow.}

This Is A Great Sentence With A $\matha$ Word.

This Is A Great Sentence With A $\mathb$ Word.

This Is A Great Sentence With A $\mathc$ Word.

This Is A Great Sentence With A $\mathd$ Word.

This Is A Great Sentence With A $\mathe$ Word.

This Is A Great Sentence With A $\mathf$ Word. I guess this is the right size, too.

{\large This Is A Great Sentence With A $\mathf$ Word. Doesn't grow.}

This Is A Great Sentence With A $\mathg$ Word.

This Is A Great Sentence With A $\mathh$ Word.
\end{document}

Somehow I think, that the first variant is to small. So I tried to enlarge it (in the correct way).


My result so far is that I found two solutions, but they do not grow with the rest of the text.

Open questions:

  1. Is the second solution "more correct" than the first? Equal? First is better?
  2. How to let both fonts grow simultaneously
  3. The second argument of fontsize has no effect. (I guess this is may only be in my example) What is the "default" value? / Which value should I use (even if it doesn't matter)

Comment: \itshape is only used, because qzcisn't available in upshape

user1
  • 2,196
  • Because it shouldn't in my point of view. \DeclareMathOperator{\wombat}{\fontfamily{qzc}\mathit{Wombat}} – Johannes_B Aug 21 '16 at 15:53
  • this doesn't work. qzc is ignored in your solution. Only mathit is used.

    Why am I using qzc: SPEZIAL is actual a mathematical class. There are more classes of this type and I think that highlighting them is a good idea

    – user1 Aug 21 '16 at 16:01
  • You are right, i haven't even noticed. \DeclareMathOperator{\wombat}{\text{\fontfamily{qzc}\itshape {Wombat}}} But it gets weirder by the minute. Maybe a more experience math and font user can help you better. Please update the question with the latest news, so it gets back on top of the main site. – Johannes_B Aug 21 '16 at 16:06
  • Your last solution has the same effects as my codelines 8-9, 29, 40. even though your solution is shorter, I find my one better/cleaner, because it also allows to use \textno{SPEZIAL} analogous to \texttt{SPEZIAL} and so on... – user1 Aug 21 '16 at 16:14
  • 1
    \normalsize will give 12pt for all fonts in the document. However, pt is a font-relative unit: how large 1pt is depends on the font. Hence, 12pt in one font may be larger or smaller than 12pt in another. This is why combinations of different fonts often scale one font to match the size of the other. – cfr Aug 21 '16 at 18:22
  • You redesigned the question after accepting an answer. That is not logical. If the answer ansered your question, that's good. If you have a follow up, ask a new question. – Johannes_B Aug 23 '16 at 19:10

1 Answers1

5

Font sizes are not standardised in the relevant sense. pt in this context is not the standard pt TeX gives you if you ask it to skip a pt to the right or draw a rule so many pts thick or whatever.

When thinking about font sizes, the size of a pt depends on the font. Hence, 12pt is a font-relative size. \normalsize is 12pt for every font in your example, but 12pt is not the same.

To see this, try

\documentclass[border=0pt,multi,tikz]{standalone}
% \usepackage{lmodern}% 3mm x 3mm
% \usepackage{venturis}% 2mm x 2mm
\usepackage[scale=1]{tgchorus}% 2mm x 2mm
\begin{document}
\begin{tikzpicture}[inner sep=0pt]
  \node [draw] {X};
\end{tikzpicture}
\end{document}

Uncommenting the different packages results in a PDF of different sizes. Some are 2mm high; some 3mm.

This is why fonts which are not originally designed to work together typically require scaling in order to create a good result. Some fonts, including Chorus are installed with scaling in mind. In these cases, it is easy to scale the font to match other fonts in the document.

I guess that you want something like this:

{\tiny This Is A Great Sentence With A $\spezial$ Word.\par}

{\scriptsize This Is A Great Sentence With A $\spezial$ Word. I guess this is the right size.\par}

{\footnotesize This Is A Great Sentence With A $\spezial$ Word.\par}

{\small This Is A Great Sentence With A $\spezial$ Word.\par}

{\normalsize This Is A Great Sentence With A $\spezial$ Word.\par}

{\large This Is A Great Sentence With A $\spezial$ Word.\par}

{\Large This Is A Great Sentence With A $\spezial$ Word.\par}

{\LARGE This Is A Great Sentence With A $\spezial$ Word. I guess this is the right size, too.\par}

{\Huge This Is A Great Sentence With A $\spezial$ Word. Doesn't grow.\par}

This Is A Great Sentence With A $\spezial$ Word.

to produce this:

scaled Chorus to match Latin Modern

or this:

{\tiny This Is A \qzctext{Great} Sentence With A $\spezial$ Word.\par}

{\scriptsize This Is A \qzctext{Great} Sentence With A $\spezial$ Word. I guess this is the right size.\par}

{\footnotesize This Is A \qzctext{Great} Sentence With A $\spezial$ Word.\par}

{\small This Is A \qzctext{Great} Sentence With A $\spezial$ Word.\par}

{\normalsize This Is A \qzctext{Great} Sentence With A $\spezial$ Word.\par}

{\large This Is A \qzctext{Great} Sentence With A $\spezial$ Word.\par}

{\Large This Is A \qzctext{Great} Sentence With A $\spezial$ Word.\par}

{\LARGE This Is A \qzctext{Great} Sentence With A $\spezial$ Word. I guess this is the right size, too.\par}

{\Huge This Is A \qzctext{Great} Sentence With A $\spezial$ Word. Doesn't grow.\par}

This Is A \qzctext{Great} Sentence With A $\spezial$ Word.

to produce this:

scaling Chorus in text and maths mode

I did this by scaling Chorus using

\newcommand*\qzc@scale{1.2}

My font configuration for Chorus looks like this

\DeclareRobustCommand\qzcstyle{%
  \fontencoding{T1}%
  \fontseries{m}%
  \fontshape{it}%
  \fontfamily{qzc}%
  \selectfont
}

for the basic command and

\DeclareTextFontCommand\qzctext{%
  \qzcstyle
}

for the text command.

For convenience, I defined

\newcommand*\textqzc[1]{\text{\qzctext{#1}}}

for use in maths mode and

\newcommand*\spezial{\textqzc{SPEZIAL}}

for testing.

Note that \text{} is doing important work in maths mode because it invokes \mathchoice to control the size and spacing of the mathematical atom in relation to other atoms.

Compare the two versions. The first is typeset with \textqzc, which uses \text{\qzctext{}}:

\[
  \sum_{\textqzc{i}=1}^n \frac{\textqzc{a}^2 + 3^{\textqzc{b}}}{\textqzc{ab}^2 + n^{\textqzc{a}}}
\]

and second simply uses \qzctext{} directly:

\[
  \sum_{\qzctext{i}=1}^n \frac{\qzctext{a}^2 + 3^{\qzctext{b}}}{\qzctext{ab}^2 + n^{\qzctext{a}}}
\]

Here's the result:

comparison: with and without \text

As can be seen, the spacing in the second version is incorrect because \qzctext{} is a text font command and does not make appropriate allowances for spacing in maths mode. The first version, using \text{} invokes \mathchoice to make the required adjustments and the spacing is correct.

Complete code:

\documentclass[a4paper, 12pt]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath}
\makeatletter
\newcommand*\qzc@scale{1.2}
\DeclareRobustCommand\qzcstyle{%
  \fontencoding{T1}%
  \fontseries{m}%
  \fontshape{it}%
  \fontfamily{qzc}%
  \selectfont
}
\makeatother
\DeclareTextFontCommand\qzctext{%
  \qzcstyle
}
\newcommand*\textqzc[1]{\text{\qzctext{#1}}}
\newcommand*\spezial{\textqzc{SPEZIAL}}

\begin{document}

% scaled Chorus in maths mode using \text{}

{\tiny This Is A Great Sentence With A $\spezial$ Word.\par}

{\scriptsize This Is A Great Sentence With A $\spezial$ Word. I guess this is the right size.\par}

{\footnotesize This Is A Great Sentence With A $\spezial$ Word.\par}

{\small This Is A Great Sentence With A $\spezial$ Word.\par}

{\normalsize This Is A Great Sentence With A $\spezial$ Word.\par}

{\large This Is A Great Sentence With A $\spezial$ Word.\par}

{\Large This Is A Great Sentence With A $\spezial$ Word.\par}

{\LARGE This Is A Great Sentence With A $\spezial$ Word. I guess this is the right size, too.\par}

{\Huge This Is A Great Sentence With A $\spezial$ Word. Doesn't grow.\par}

This Is A Great Sentence With A $\spezial$ Word.

% scaled Chorus in text and maths modes

{\tiny This Is A \qzctext{Great} Sentence With A $\spezial$ Word.\par}

{\scriptsize This Is A \qzctext{Great} Sentence With A $\spezial$ Word. I guess this is the right size.\par}

{\footnotesize This Is A \qzctext{Great} Sentence With A $\spezial$ Word.\par}

{\small This Is A \qzctext{Great} Sentence With A $\spezial$ Word.\par}

{\normalsize This Is A \qzctext{Great} Sentence With A $\spezial$ Word.\par}

{\large This Is A \qzctext{Great} Sentence With A $\spezial$ Word.\par}

{\Large This Is A \qzctext{Great} Sentence With A $\spezial$ Word.\par}

{\LARGE This Is A \qzctext{Great} Sentence With A $\spezial$ Word. I guess this is the right size, too.\par}

{\Huge This Is A \qzctext{Great} Sentence With A $\spezial$ Word. Doesn't grow.\par}

This Is A \qzctext{Great} Sentence With A $\spezial$ Word.
\end{document}
cfr
  • 198,882
  • comment/question: wouldn't be \newcommand*\textqzc[1]{\qzctext{#1}} instead of \newcommand*\textqzc[1]{\text{\qzctext{#1}}} cleaner. The second one produces minimal more whitespace – user1 Aug 21 '16 at 21:04
  • 1
    \qzctex{#1} will not work. \qzctext{#1} will work. – cfr Aug 21 '16 at 21:09
  • See also my answer regarding \newcommand and friends. (Possibly helpful. Then again, possibly not.) That definition of \spezial is identical to the one I gave. Are you talking about using \newcommand*\spezial{\qzctext{SPEZIAL}}? – cfr Aug 21 '16 at 21:30
  • @Johannes_B Thanks. Fairly recently, I guess. I forget exactly. It is in the chat transcript if you want to know badly enough, though I can't imagine why you would ;). – cfr Aug 22 '16 at 22:25
  • 1
    @Ben If you have a follow up, ask a new question. – Johannes_B Aug 23 '16 at 19:10
  • @Ben I think deleting comments which are off-topic or have been addressed (e.g. problems caused by typos) or which the answer has been edited to accommodate can generally be deleted to good effect. – cfr Aug 23 '16 at 22:25