2

Using \textgoth in math mode is generally fine, as in the first image below, but when I also have \usepackage{anyfontsize}, an issue occurs.

MWE:

\documentclass{article}

\usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsthm} %\usepackage{anyfontsize}

\usepackage{yfonts}

\begin{document} \textgoth{Re} \textgoth{Im}\

$\textgoth{Re}(z) \textgoth{Im}(z)$ $$\textgoth{Re}(z), \textgoth{Im}(z)$$ $$\textgoth{Im}(z), \textgoth{Re}(z)$$ \textgoth{Re} \textgoth{Im} \end{document}

yields enter image description here but with the \usepackage{anyfontsize} included yields enter image description here Note that very strangely, the first $\textgoth{Re}$ works, but every one after that, even the ones in normal text (not math mode) are super small. I am also running in Overleaf, if that is important to know.

David Carlisle
  • 757,742
D.R
  • 771
  • 2
    seems odd but not inclined to fix, there really isn't any need for anyfontsize these days all fonts except cm are scalable by default and cm can be scalable with fix-cm – David Carlisle Oct 26 '21 at 18:46
  • @DavidCarlisle what do you mean scalable by default? Is there a tex.SE answer or reference I can read to have an overview (I briefly googled "anyfontsize latex" online and did not see anything saying it was "retired" or anything)? Anyways thanks for the comment, I suppose I can safely delete it. – D.R Oct 26 '21 at 18:50
  • 1
    There are thousands of packages on ctan most are never retired. some get less useful over time some don't have obvious uses ever. it is what it is. but for almost all fonts you can already do \fontsize{3cm}{4cm}\selectfont or whatever size you want so it's not clear what you want the package to do. What was the use case that caused you to add it? – David Carlisle Oct 26 '21 at 18:54
  • 1
    not an explanation, but the problem seems to be avoided if you provide the fontsize option to the document class, or explicitly set it using the \fontsize command. – Dan MacKinnon Oct 26 '21 at 18:54
  • @D.R Maybe you can take a look at the fontsize package (more up to date and covers almost everything) – Pablo González L Oct 26 '21 at 18:55
  • Off-topic: $$...$$ are depreciated: https://tex.stackexchange.com/questions/410863/what-are-the-differences-between-and – Sebastiano Oct 26 '21 at 22:50
  • 1
    anyfontsize package is expecting to be told a font size (since that is its purpose: it "lets the user select any font size (via e. g. \fontsize{...}{...}\selectfont), even those sizes that are not listed in the .fd file. If such a size is requested, LATEX will search the nearest listed size, and anyfontsize will scale that font to the requested size". Not being told what font size to use caught it by surprise (in the part where it compares things when looking for a best size). – Cicada Oct 27 '21 at 11:22

2 Answers2

2

You can rework the font definitions to avoid discrete sizes.

\documentclass{article}

\usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsthm} \usepackage{anyfontsize}

\usepackage{yfonts} % do the declarations here \DeclareFontEncoding{LY}{}{} \DeclareFontSubstitution{LY}{yfrak}{m}{n} \DeclareFontEncoding{LYG}{}{} \DeclareFontSubstitution{LYG}{ygoth}{m}{n} \DeclareFontFamily{LYG}{ygoth}{} \DeclareFontShape{LYG}{ygoth}{m}{n}{<->ygoth}{} \DeclareFontFamily{LY}{yfrak}{} \DeclareFontShape{LY}{yfrak}{m}{n}{<->yfrak}{} \DeclareFontFamily{LY}{ysmfrak}{} \DeclareFontShape{LY}{ysmfrak}{m}{n}{<->ysmfrak}{} \DeclareFontFamily{LY}{yswab}{} \DeclareFontShape{LY}{yswab}{m}{n}{<->yswab}{}

\begin{document}

\textgoth{Re} \textgoth{Im}

$\textgoth{Re}(z) \textgoth{Im}(z)$ \begin{gather} \textgoth{Re}(z), \textgoth{Im}(z) \ \textgoth{Im}(z), \textgoth{Re}(z) \end{gather} \textgoth{Re} \textgoth{Im}

\end{document}

enter image description here

However, you don't really need anyfontsize. Better to load fix-cm with \RequirePackage{fix-cm} before \documentclass if you stay with the OT1 encoding. Otherwise the standard \usepackage{fix-cm} is sufficient. Anyway, keep the code I showed.

egreg
  • 1,121,712
1

A unicode-math way, for comparison, using Asana Math font as an example font:

unicode

Interestingly, direct input is allowed for the math alphabets (that is, typing ℜ ℛ ℝ directly, rather than using macros).

MWE

\documentclass{article}

\usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsthm} %\usepackage{anyfontsize} %\usepackage{yfonts} \usepackage{xcolor}

\newcommand\fmathfontname{Asana Math} \usepackage{unicode-math} \setmathfont{\fmathfontname} \newcommand{\textgoth}[1]{\symfrak{#1}} \newfontface\fmymaths{\fmathfontname}[Colour=blue] \DeclareTextFontCommand{\mytextfrak}{\fmymaths} \newcommand\myreal{ℜ} \newcommand\myimaginary{ℑ}

\begin{document} Text mode, direct input:

\mytextfrak{\myreal} \mytextfrak{\myimaginary}

\bigskip Math mode:

$(\textgoth{Re}(z), \textgoth{Im}(z)) ≡ (ℜ(z), ℑ(z)) $ [\textgoth{Re}(z), \textgoth{Im}(z)] [\textgoth{Im}(z), \textgoth{Re}(z)]

Text mode:

\mytextfrak{\myreal} \mytextfrak{\myimaginary}

\bigskip Math mode, direct input:

[ ℜ ℛ ℝ ]

\end{document}

Cicada
  • 10,129