Graphics, Figures & Tablestikz - change default measuring units (from cm to em) ?

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

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

Post by mike-klemin »

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

Code: Select all

\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

Code: Select all

\draw (0,0) -- (1.414em,1);
But it's just too rude...

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

CDbile
Posts: 19
Joined: Mon Jan 31, 2011 6:48 pm

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

Post by CDbile »

You can instead change the default length of the axis :

Code: Select all

\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} :

Code: Select all

\documentclass{minimal}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[x=1em,y=1em]

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

\end{tikzpicture}
\end{document}
CDbile
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

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

Post by localghost »

A global setting is also possible.

Code: Select all

\documentclass{minimal}
\usepackage{tikz}

\tikzset{x=1em,y=1em}

\begin{document}
  \begin{tikzpicture}
    \draw (0,0) -- ({sqrt(2)},1);
  \end{tikzpicture}
\end{document}

Thorsten
Post Reply