LaTeX forum ⇒ Graphics, Figures & Tablestikz - 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) ?

Postby mike-klemin » Sat Apr 02, 2011 9:00 pm

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

  1. \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
  1. \draw (0,0) -- (1.414em,1);

But it's just too rude...

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

Postby CDbile » Wed Apr 06, 2011 6:00 pm

You can instead change the default length of the axis :

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

  1. \documentclass{minimal}
  2. \usepackage{tikz}
  3.  
  4. \begin{document}
  5. \begin{tikzpicture}[x=1em,y=1em]
  6.  
  7. \draw (0,0) -- ({sqrt(2)},1);
  8.  
  9. \end{tikzpicture}
  10. \end{document}
CDbile

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Wed Apr 06, 2011 6:11 pm

A global setting is also possible.
  1. \documentclass{minimal}
  2. \usepackage{tikz}
  3.  
  4. \tikzset{x=1em,y=1em}
  5.  
  6. \begin{document}
  7. \begin{tikzpicture}
  8. \draw (0,0) -- ({sqrt(2)},1);
  9. \end{tikzpicture}
  10. \end{document}



Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


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


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 7 guests