# Creating a custom font size

In this query, @MartinSharrer provides a nice macro to create a custom fontsize. Unfortunately, I don't understand how to use it.

The code below uses his macro

\documentclass{beamer}
\newlength{\mylength}
\makeatletter
\newcommand{\mycfs}[1]{%
\normalsize
\@defaultunits\mylength=#1pt\relax\@nnil
\edef\@tempa{{\strip@pt\mylength}}%
\ifx\protect\@typeset@protect
\edef\@currsize{\noexpand\mycfs\@tempa}% store calculated size
\fi
\mylength=1.2\mylength
\edef\@tempa{\@tempa{\strip@pt\mylength}}%
\@tempa
\expandafter\fontsize\@tempa
\selectfont
}
\makeatother
\begin{document}
{\mycfs{8} This is a test} \\
{\mycfs{7} This is a test} \\
{\mycfs{6} This is a test} \\
{\mycfs{5} This is a test} \\
\end{document}


But produces this output .

The font selection part is great but I can't figure out how to remove the numbers at the beginning of each line. Could somebody advise please?

• Why can't you just use \fontsize ? (as in flav's answer) – David Carlisle Nov 21 '17 at 8:59

I can't figure out how to remove the numbers at the beginning of each line.

Simply remove the line that contains just \@tempa.

using fontsize and selectfont (https://en.wikibooks.org/wiki/LaTeX/Fonts):

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[french]{babel}

\begin{document}

Coucou

\fontsize{14pt}{14pt}\selectfont
Coucou

\fontsize{28pt}{28pt}\selectfont
Coucou

\end{document}