# Defining font size in standalone with xelatex

I want to produce svg images of tikz pictures in a standalone environment that match the main document. So far everything works just fine. However, I am struggeling with defining the fontsize of the main document, which in this case is a beamer presentation with fontsize 9pt. How is it possible to set normalfontsize to 9pt in the standalone too?

MWE of main document:

\documentclass[9pt]{beamer}
\usepackage{fontspec}
\setmainfont{Arial}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

\draw (-0.4,0) -- (10.6,0);

\node[anchor=north east,align=right, inner sep=2mm, yshift=-0.5cm, xshift=0cm,font=\centering\bfseries\huge](a) at (current bounding box.east){This is the Main Title:};

\node[anchor=north east,align=right, inner sep=2mm, yshift=0.2cm, xshift=0cm,font=\centering\bfseries\large](b) at (a.south east){And this is the Subtitle that fits within the black border lines.};

\node[anchor=north east,align=right, inner sep=2mm, yshift=-0.4cm, xshift=0cm,font=\centering](c) at (b.south east){Name 1, Name 2};

\draw (-0.4,0) -- (-0.4,-5);
\draw (10.6,0) -- (10.6,4.5);
\end{tikzpicture}

\end{document}


MWE of the Standalone:

\documentclass[crop,tikz,convert=pdf2svg]{standalone}
\usepackage[inkscapelatex=false]{svg}
\usepackage{fontspec}
\setmainfont{Arial}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

\draw (-0.4,0) -- (10.6,0);

\node[anchor=north east,align=right, inner sep=2mm, yshift=-0.5cm, xshift=0cm,font=\centering\bfseries\huge](a) at (current bounding box.east){This is the Main Title:};

\node[anchor=north east,align=right, inner sep=2mm, yshift=0.2cm, xshift=0cm,font=\centering\bfseries\large](b) at (a.south east){And this is the Subtitle that fits within the black border lines.};

\node[anchor=north east,align=right, inner sep=2mm, yshift=-0.4cm, xshift=0cm,font=\centering](c) at (b.south east){Name 1, Name 2};

\draw (-0.4,0) -- (-0.4,-5);
\draw (10.6,0) -- (10.6,4.5);
\end{tikzpicture}

\end{document}


MWE of the standalone gives:

• Your each node has a compulsory argument delimited by { & }. You can add font-sizes like large, small, footnotesize, normalsize in those delimiters. eg. {\normalsize This is the main title} Try on your own, if you didn't get it, I'll post an example-answer. Feb 24, 2020 at 15:30
• Sorry, your MWE doesn't work as one expected. It contain flaws in style definitions, current bounding box is in time of using unknown, drawn lines are over text and partly invisible .... Please provide a sketch, that you like to have (i suspect that right aligned titles and names with lines around). I took a liberty and add to your question a image what your MWE produce. Feb 24, 2020 at 16:00

It is not clear what you like to get. I suspect that one from the following examples:

generated by:

\documentclass[margin=1mm,% added that border is better visible
% in real document you can delete margin
tikz,convert=pdf2svg]{standalone}
%\documentclass[tikz, margin=1mm]{standalone}
\usetikzlibrary{fit,
positioning}
\usepackage[inkscapelatex=false]{svg}
\usepackage{fontspec}
\setmainfont{Arial}

\begin{document}
\begin{tikzpicture}[
node distance = 2mm and 0mm,
box/.style = {inner sep=1mm, font=\bfseries#1,
anchor=north east}
]
\node[box=\huge](a)
{This is the Main Title:};
\node[box=\large, below left=of a.south east](b)
{And this is the Subtitle that fits within the black border lines.};
\node[box=\normalsize, below left=7mm and 0mm of b.south east](c)
{Name 1, Name 2};
%
\node[draw, inner sep=2mm, fit=(a) (b) (c)] {};
\end{tikzpicture}
\end{document}


or

produced by:

\documentclass[margin=1mm,% added that border is better visible
% in real document you can delete margin
tikz,convert=pdf2svg]{standalone}
%\documentclass[tikz, margin=1mm]{standalone}
\usetikzlibrary{fit,
positioning}
\usepackage[inkscapelatex=false]{svg}
\usepackage{fontspec}
\setmainfont{Arial}

\begin{document}
\begin{tikzpicture}[
node distance = 2mm and 0mm,
box/.style = {inner sep=1mm, font=\bfseries#1}
]
\node[box=\huge](a)
{This is the Main Title:};
\node[box=\large, below=of a](b)
{And this is the Subtitle that fits within the black border lines.};
\node[box=\normalsize,
below=7mm of b](c)
{Name 1, Name 2};
%
\node[draw, inner sep=2mm, fit=(a) (b) (c)] {};
\end{tikzpicture}
\end{document}


• by \documentclass[crop,tikz,convert=pdf2svg]{standalone} is loaded tikz package, therefore it is not needed to load it again with \usepackage{tikz}
• in nodes, which haven't defined text width the content of node is always in the middle of node, so defining align=... has no sense
• for font doesn't exist option \centering
• all nodes style definition differ only in used font size, consequently it is sensible to define common node shape style with free parameter which determine font size (by this code become more shorter and clear)
• it seems that (final) current bounding box is in time of its using unknown

Adddendum: The case, that you like to have this titles when are to long in more lines. This can be accomplished, with prescribing text width in node shape style options:

\documentclass[margin=1mm,% added that border is better visible
tikz,convert=pdf2svg]{standalone}
\usetikzlibrary{fit,
positioning}
\usepackage[inkscapelatex=false]{svg}
\usepackage{fontspec}
\setmainfont{Arial}

\begin{document}
\begin{tikzpicture}[
node distance = 2mm and 0mm,
box/.style = {text width=11cm, align=right,
inner sep=1mm, font=\bfseries#1}
]
\node[box=\huge](a)
{This is the Main Title:};
\node[box=\large, below=of a](b)
{And this is the Subtitle that fits within the black border lines.};
\node[box=\normalsize,
below=7mm of b](c)
{Name 1, Name 2};
%
\node[draw, inner sep=2mm, fit=(a) (b) (c)] {};
\end{tikzpicture}
\end{document}


or with centered text:

\documentclass[margin=1mm,% added that border is better visible
% in real document you can delete margin
tikz,convert=pdf2svg]{standalone}
\usetikzlibrary{fit,
positioning}
\usepackage[inkscapelatex=false]{svg}
\usepackage{fontspec}
\setmainfont{Arial}

\begin{document}
\begin{tikzpicture}[
node distance = 2mm and 0mm,
box/.style = {text width=11cm, align=center,
inner sep=1mm, font=\bfseries#1}
]
\node[box=\huge](a)
{This is the Main Title:};
\node[box=\large, below=of a](b)
{And this is the Subtitle that fits within the black border lines.};
\node[box=\normalsize,
below=7mm of b](c)
{Name 1, Name 2};
%
\node[draw, inner sep=2mm, fit=(a) (b) (c)] {};
\end{tikzpicture}
\end{document}


• Thank you very much for the code advancements Zarko! They help me a lot! Feb 25, 2020 at 5:57
• @kilsen, you are welcome! Please let me know, if you answers are close to what you like to have. Now I think, that you may like to have multi line titles, if they are to long. For any case I will add an example for it. Feb 25, 2020 at 7:47
• @kilsen, any news? Does any of showed example is what you looking for? Feb 25, 2020 at 21:54
• Dear Zarko, actually not yet. I added the MWE of the main file (I don't know how you attached a rendered version of that to the post). Since it is using beamer class where I can define fontsize 9pt, it fits into the border. However, in the standalone version, I don't know how to define the 9pt fontsize and it produces the overshoot. Therefore, I would like to know how to set fontsize 9pt in the standalone version while using xelatex with fontspec, that it completely resembles the main document. Feb 27, 2020 at 10:39