Graphics, Figures & Tablestikzpicture coordinates

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
asafw
Posts: 37
Joined: Sun Jun 10, 2012 12:33 pm

tikzpicture coordinates

Post by asafw »

Hi,

I'm trying to use tikzpicture to draw a circle as follows, but when I change coordinates -- say, from (0,0) to (10,0) -- this has no effect on positioning. Any idea why? (or should I submit a full MWE?)

Thanks so much,
Asaf

Code: Select all

\begin{frame}
\begin{tikzpicture}
\draw (0,0) ellipse (2cm and .5cm);
\end{tikzpicture}
\end{frame}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

tikzpicture coordinates

Post by Stefan Kottwitz »

Hi Asaf!

Yes, a full MWE is always good. You know, we cannot test without an MWE, and every time somebody posts a code snippet we have to build an MWE ourselves. That's because we always want to post properly tested solutions, verified that they work.

The coordinates have effect on the positioning within the TikZ picture. But the picture contains only the ellipse, it is automatically cut, the bounding box is just big enough to contain what you have drawn. So, one time it contains the coordinate (0,0), at the other time when you just change the coordinates it starts at (0,10) where your actual drawing content starts. So it looks the same on your beamer slide, just with different coordinates within.

A quick fix is: add an empty node at (0,0). So the drawing contains the node (0,0) and your ellipse at (0,10), then you see the positioning changes.

Code: Select all

\documentclass{beamer} 
\usepackage{tikz}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\node at (0,0) {}; 
\draw (0,10) ellipse (2cm and .5cm);
\end{tikzpicture}
\end{frame}
\end{document}
Full MWE. :-) So a reader can test, for example by just on click on "Open in Overleaf" at the top of the code. That's why I use a code box for LaTeX code: syntax highlighting, readability, one-click online compiling. That's done with the Code button when editing (mark text, click Code).

Stefan
LaTeX.org admin
Post Reply