For the sizes, you can use the current bounding box
together with \pgfgetlastxy
:
\documentclass{standalone}
\usepackage{tikz}
\newcommand*{\ExtractCoordinate}[3]{\path (#1); \pgfgetlastxy{#2}{#3};}%
\newdimen\tlx
\newdimen\tlx
\newdimen\brx
\newdimen\bry
\begin{document}
\begin{tikzpicture}
\draw (-3,-1) rectangle (3,1) (-2,-2) rectangle (2,2);
\foreach \x in {north west,south west,south east,north east}
{ \fill[red] (current bounding box.\x) circle (0.01);
}
\ExtractCoordinate{current bounding box.north west}{\tlx}{\tly}
\ExtractCoordinate{current bounding box.south east}{\brx}{\bry}
\pgfmathsetmacro{\myheight}{(+\tly-\bry)/28.452755}
\pgfmathsetmacro{\mywidth}{(-\tlx+\brx)/28.452755}
\node[below right] at (-2,1) {height: \myheight\ cm};
\node[above left] at (2,-1) {width: \mywidth\ cm};
\end{tikzpicture}
\end{document}
Edit 1: Ah, now I get it. Here is a still not automatic version. You set two commands in each tikzpicture
:
\maximumdimensions{4}{3}
, which is the desired width and height, at the beginning of the picture.
\getscalingfactors
which will draw nodes with a recommended scaling factor in the middle of your picture if the image if to high/wide:
\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{xifthen}
\newcommand*{\ExtractCoordinate}[3]{\path (#1); \pgfgetlastxy{#2}{#3};}%
\newdimen\tlx
\newdimen\tlx
\newdimen\brx
\newdimen\bry
\def\xscalefactor{}
\def\yscalefactor{}
\parindent0mm
\newcommand{\getscalingfactors}{%
\ExtractCoordinate{current bounding box.north west}{\tlx}{\tly}
\ExtractCoordinate{current bounding box.south east}{\brx}{\bry}
\pgfmathsetmacro{\myheight}{(+\tly-\bry)/28.452755}
\pgfmathsetmacro{\mywidth}{(-\tlx+\brx)/28.452755}
\pgfmathsetmacro{\xsf}{\maxwidth/\mywidth}
\pgfmathsetmacro{\ysf}{\maxheight/\myheight}
\global\edef\xscalefactor{\xsf}
\global\edef\yscalefactor{\ysf}
\pgfmathtruncatemacro{\xsfc}{\xsf*10000}
\pgfmathtruncatemacro{\ysfc}{\ysf*10000}
\ifthenelse{\xsfc > 10000}{}{\node[fill=white,above] at (current bounding box.center) {x-s: \xsf};}
\ifthenelse{\ysfc > 10000}{}{\node[fill=white,below] at (current bounding box.center) {y-s: \ysf};}
}
\newcommand{\maximumdimensions}[2]{% width, height
\global\edef\maxwidth{#1} % in cm
\global\edef\maxheight{#2} % in cm
}
\begin{document}
\begin{tikzpicture}[scale=1]
\maximumdimensions{4}{3}
\draw[fill=orange] (-3,-1) rectangle (3,1) (-2,-2) rectangle (2,2);
\getscalingfactors
\end{tikzpicture}
\lipsum[1]
\begin{tikzpicture}[scale=1]
\maximumdimensions{4}{3}
\draw[fill=orange!50!gray] (0,0) circle (3);
\draw[fill=red!50!gray] (3,1) circle (1);
\draw[fill=blue!50!gray] (-2,2) circle (1);
\draw[fill=green!50!gray] (-3,-2) circle (1);
\draw[fill=yellow!50!gray] (2,-1) circle (1);
\getscalingfactors
\end{tikzpicture}
\end{document}
If you scale the picture down enough, the nodes inside the picture vanish:
\begin{tikzpicture}[scale=0.66]
and \begin{tikzpicture}[scale=0.497]
Tools -> Manage Note Types... -> Options; in the last line of the Header field after \begin{document}
just type
\tiny
And your LaTeX will be made smaller. Because previously rendered latex is cached as image files, you may have to delete those files before the change is apparent. On my Mac the files are in ~/Anki/User 1/collection.media/latex-*.png
For me this makes my [$$][/$$]
equations the same size as the surrounding Anki font.
I hope this helps!
UPDATE: On Linux, the media directory seems to be located in ~/Documents/Anki/User 1/collection.media/
Best Answer
I'm not sure the question is really answerable. It mentions several essentially unrelated commands and asks when they should be used, but I'll have a go.
\DeclareMathSizes
should be used almost never. It defines for a given text font size, what size font to use for math node at text and script sizes. The values predeclared in the LaTeX format will cover the vast majority of cases. You would only using this if writing a class that had a very different set of supported font sizes to the standard classes or were writing a package loading a math font suite that is very different to computer modern (for example some fonts may require script and scriptscript text to be set slightly larger to be readable, computer modern fonts are designed at small point sizes to be legible but if you are using a scalable font with just a single design mechanically scaled you may want to prevent sub-subscripts being too small.\textstyle
\scriptstyle
are user level commands in math that force the font style that TeX would normally use automatically in certain constructs so$\scriptstyle b$
and$a^{b}$
the b uses the same font in both cases. It's not possible to give general rules why you should want to do this, it is just an available control. One common reason is to force entries in arrays (which would by default be set as\textstyle
to display style by issuing\displaystyle
. (AMS and similar alignment environments do this as part of their definition.)\tiny
\small
may not be used in math mode they set the font for text mode use (math fonts are normally sized to match though, according to the sizes specified by\DeclareMathSizes
). Normally in a document one should avoid explicit size (or font) changes and use logical markup such as\section
or\footnote
, but they can be useful sometimes, eg to reduce the font to squeeze in a large table.