LaTeX forum ⇒ Graphics, Figures & Tables ⇒ tikz - change default measuring units (from cm to em) ?

Information and discussion about graphics, figures & tables in LaTeX documents.
mike-klemin
Posts: 8
Joined: Fri Feb 18, 2011 9:50 pm

tikz - change default measuring units (from cm to em) ?

Hello!
Probably the subject a little bit miss informative. But not sure how to formulate it better..

Actually I stuck at point where I have to draw a path which coordinates use sqrt(Xem) like

\draw (0,0) -- ({sqrt(2)},1);

It works, but I need to calculate square root from 2em and not from 2cm as it calculates by default. I tried to add "em" everywhere it would make a sense, but it just didn't worked...

I just can not figure how to do that?
Yes, I can just use calculator and make it
\draw (0,0) -- (1.414em,1);

But it's just too rude...

CDbile
Posts: 19
Joined: Mon Jan 31, 2011 6:48 pm
You can instead change the default length of the axis :

\draw[x=1em,y=1em] (0,0) -- ({sqrt(2)},1);

If you want to use this length in your whole picture, you can just put the option after the \begin{tikzpicture} :

\documentclass{minimal}\usepackage{tikz} \begin{document}\begin{tikzpicture}[x=1em,y=1em] \draw (0,0) -- ({sqrt(2)},1); \end{tikzpicture}\end{document}
CDbile

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
A global setting is also possible.
\documentclass{minimal}\usepackage{tikz} \tikzset{x=1em,y=1em} \begin{document}   \begin{tikzpicture}     \draw (0,0) -- ({sqrt(2)},1);   \end{tikzpicture}\end{document}

Thorsten
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1