Graphics, Figures & TablestikZ | Fixed Length for a Line Segment

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

tikZ | Fixed Length for a Line Segment

Post by ghostanime2001 »

How do you make the line segment between two nodes fixed regardless of weather the nodes are placed relative to a coordinate ?

Code: Select all

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,chains,matrix}

\pagestyle{empty}

\begin{document}
\begin{tikzpicture}
\draw (0,0) node (A) {A};
\draw (30pt,0) node[above right] (B) {B};
\draw (A) -- (B);
\end{tikzpicture}
The line segment in between is not 30 points long even though the nodes are 30 points apart.
\end{document}

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply