Edit: The example I originally gave was quite flawed - I'll leave it there but the second part is the bit I'm really struggling with.
Original Question A similar question to this thread but I'm not using pgfplotsset so the solution didn't work for me.
I'm developing a tool to help me generate diagrams. For some reason, to draw the below diagram:
I have to generate the tikz:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\title{Diagram Practice}
%\author{Jack Turner}
\date{}
\begin{document}
\tikzstyle{box}=[minimum size = 1.25cm,right=10mm, rectangle, draw=black, fill=white, thick]
\begin{tikzpicture}
\draw[black] (1.,0.) -- (2.,0.);
\node[box] (f) at (1.,0.) {$f$};
\draw[black] (3.25,-0.208333333333) -- (3.5,-0.208333333333);
\draw[black] (3.25,0.208333333333) -- (3.5,0.208333333333);
\end{tikzpicture}
\end{document}
It seems silly to me that I have to place a path from (1,0) -- (2,0) for the wire coming in from the left when the box is placed at (1,0). Why is it not a path from (0,0) -- (1,0)? Edit: this was because of the right = 10mm
in my styling
Moreover, why doesn't the box get placed at the origin? Why does the path hit the box in the centre instead of being aligned to the bottom?
The scaling seems to get more complicated as the diagrams get larger - so if I have three boxes put next to each other and I try to connect them it's almost impossible to get the wires connecting them to actually touch the edge of the box.
Is there a way to stop tikz from making these relative adjustments?
Question 2
If I do:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\title{Diagram Practice}
%\author{Jack Turner}
\date{}
\begin{document}
\tikzstyle{box}=[minimum size = 1.25cm,right=10mm, rectangle, draw=black, fill=white, thick]
\begin{tikzpicture}
\node[box] (f) at (1.,0.) {$f$};
\node[box] (h) at (7.,0) {$h$};
\end{tikzpicture}
\end{document}
The nodes draw nicely:
But if I remove the left node:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\title{Diagram Practice}
%\author{Jack Turner}
\date{}
\begin{document}
\tikzstyle{box}=[minimum size = 1.25cm,right=10mm, rectangle, draw=black, fill=white, thick]
\begin{tikzpicture}
\node[box] (h) at (7.,0) {$h$};
\end{tikzpicture}
\end{document}
The node shifts to where the f
node used to be. How do I get h
to stay in exactly the same spot? Is that something that LaTeX is doing to the diagram or is that a tikz thing?
\documentclass{...}
and ending with\end{document}
instead of code snippets. This makes our lives easier and increases the chance of people helping you.xshift
in thebox
style, but please don't make us reverse engineer your code, it makes it harder and more time consuming to answer, and it's a pointless exercise to start with. As for the box placement, nodes are by default placed quite logically, with the center point in the specified coordinate. You can change that by specifying ananchor
for the node though.tikzpicture
relate by default only to thetikzpicture
itself, they have no relation to the page. Thetikzpicture
is a rectangular box that fits around its content, and LaTeX just sees a box, that it places on the current line just as any other box, e.g. an\includegraphics
, or the letterX
. You can place stuff relative to the page though, see e.g. tex.stackexchange.com/questions/89588/…