0

In the below-simplified Latex code, I'm using scale to change the font size of the math mode.

\documentclass[convert={density=300,size=1080x800,outext=.png},tikz]{standalone}
\usepackage{xcolor}
\usepackage{scalerel}
\usetikzlibrary{arrows.meta,backgrounds}
\tikzset{white background/.style={show background rectangle,tight background,background rectangle/.style={fill=white } } }

\begin{document} \begin{tikzpicture}[white background] \draw node[draw, fill={{rgb:black,0;white,5}}, minimum size=4cm,line width=0.1cm, label={ [yshift=-6cm] { $\scaleto{1 2 3x_{ 18 } }{ 20pt }$ } } ] at (25, 20) { $\scaleto{ 0 }{ 30pt }$ }; \path (current bounding box.north east) +(15mm,15mm) (current bounding box.south west) +(-15mm,-15mm); \end{tikzpicture} \end{document}

enter image description here

When only math elements exist (inside of the box), there is no problem. As we can see, however, if there are text and math to display the scale doesn't work;

  • Math mode removes the spaces, as usual
  • Math mode doesn't have \text in Tikz as Latex.

What is the correct way to scale both of them?

kelalaka
  • 395

1 Answers1

2

Why, just include the amsmath package, and use \text{...} wherever you like---

\documentclass[convert={density=300,size=1080x800,outext=.png},tikz]{standalone}
\usepackage{xcolor}
\usepackage{scalerel}
\usepackage{amsmath}
\usetikzlibrary{arrows.meta,backgrounds}
\tikzset{white background/.style={show background rectangle,tight background,background rectangle/.style={fill=white } } }

\begin{document} \begin{tikzpicture}[white background] \draw node[draw, fill={{rgb:black,0;white,5}}, minimum size=4cm,line width=0.1cm, label={ [yshift=-6cm] { $\scaleto{1 2 3x_{ 18 } \text{x} }{ 30pt }$ } } ] at (25, 20) { $\scaleto{ a, 0, \text{a} }{ 30pt }$ }; \path (current bounding box.north east) +(15mm,15mm) (current bounding box.south west) +(-15mm,-15mm); \end{tikzpicture} \end{document}

to get both text and math scaled to the sizes mentioned...

scaled-text-math

Edit

To show how it looks with space between texticized numerals... \text{1 2 3}x_18 \text{x}

scale-text-maths

Partha D.
  • 2,250
  • Great!. I prefer this $\scaleto{\text{1 2 3 }x_{ 18 } }... in the answer since I've intentionally written 1 2 3 with spaces. – kelalaka May 15 '21 at 17:49
  • 1
    That's one way-- no doubt ! Another way is to include forced spaces with \,, \: or \; (or, if you need even thicker spaces, \quad or \qquad) even in the math-mode... thanks to the amsmath package developers :) – Partha D. May 15 '21 at 17:54
  • Now the LFSR automatic drawing and animations are finished. Thanks to you and the previous answerers, too. 1 and 2 – kelalaka May 15 '21 at 22:35