One simple solution is to reduce the width
of the first arrow with the calc
library.
Example:
\documentclass[a4paper]{article}
\usepackage{tikz}
\usepackage{amsmath,amssymb}
\usetikzlibrary{matrix,arrows,calc}
\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of math nodes, row sep=1.5em, column sep=2.5em, text height=1.5ex, text depth=0.25ex]
{ \mathbb{C}[x_1,...,x_s]/J(f) & \mathbb{C}[x_1,...,x_s]/J(g)\\
\mathbb{C}[x]/\langle J(f),x_{s+1},...,x_n\rangle & \mathbb{C}[x]/\langle J(g),x_{s+1},...,x_n\rangle\\ };
\path[->]
($(m-1-1.east)+(0.5,0)$) edge node[above] {$\sim$} ($(m-1-2.west)-(0.5,0)$)
(m-2-1) edge[dashed] node[above] {$\sim$} (m-2-2);
\draw[transparent]
(m-1-1) edge node[rotate=270,opacity=1] {$\cong$} (m-2-1)
(m-1-2) edge node[rotate=270,opacity=1] {$\cong$} (m-2-2);
\end{tikzpicture}
\end{document}
Graphical solution:
This could be an approach if that is the only picture you have to adjust otherwise it is possible to automate more the process: 1) based on @percusse comment, 2) using TikZ: How to determine the vector between two co-ordinates to determine the length of the shortest arrow and adapt the other arrows to that.
EDIT by percusse
One can take the orthogonal intersection of different nodes via (m-1-1 -| m-2-1.east) edge node[above] {$\sim$} (m-1-2 -| m-2-2.west)
which would allow to get the vertical component of the row and the horizontal component of the end and the start points of the second row entries respectively.
To automate further, one can fix node text width such that every cell would inherit the same text width and centered. Passing the options to the individual cells is possible via nodes={.....}
key supplied to the matrix
\documentclass{standalone}
\usepackage{tikz}
\usepackage{amsmath,amsfonts}
\usetikzlibrary{matrix,arrows}
\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,
row sep=1.5em,
column sep=2.5em,
nodes={
text width=4cm,
align=center
}
]
{ \mathbb{C}[x_1,...,x_s]/J(f) & \mathbb{C}[x_1,...,x_s]/J(g)\\
\mathbb{C}[x]/\langle J(f),x_{s+1},...,x_n\rangle & \mathbb{C}[x]/\langle J(g),x_{s+1},...,x_n\rangle\\ };
\path[->]
(m-1-1) edge node[above] {$\sim$} (m-1-2)
(m-2-1) edge[dashed] node[above] {$\sim$} (m-2-2);
\draw[transparent]
(m-1-1) edge node[rotate=270,opacity=1] {$\cong$} (m-2-1)
(m-1-2) edge node[rotate=270,opacity=1] {$\cong$} (m-2-2);
\end{tikzpicture}
\end{document}
You can specify which is the length
of the arrow in this way:
\draw[->, thick] (3,1.5) -- ($(3,1.5)!1cm!(0,1.5)$);
where the length
is 1cm
.
Here is the revised example:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0,0) -- (6,0) -- (6,3) -- (0, 3) -- cycle;
\draw[->, thick] (3,1.5) -- ($(3,1.5)!1cm!(0,1.5)$);
\draw[->, thick] (3,1.5) -- ($(3,1.5)!1cm!(6,1.5)$);
\draw[->, thick] (3,1.5) -- ($(3,1.5)!1cm!(3,3)$);
\draw[->, thick] (3,1.5) -- ($(3,1.5)!1cm!(3,0)$);
\shade[shading=ball, ball color=black!90] (3,1.5) circle (0.25em);
\end{tikzpicture}
\end{document}
The result:
You can find more information on the calc
library on the documentation (13.5 Coordinate Calculations, pgfmanual version October 25, 2010).
A quickest implementation:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newlength\arrowlength
\setlength{\arrowlength}{1cm}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0,0) -- (6,0) -- (6,3) -- (0, 3) -- cycle;
\foreach \destination in
{{0,1.5},{6,1.5},{3,3},{3,0}}
\draw[->, thick] (3,1.5) -- ($(3,1.5)!\arrowlength!(\destination)$);
\shade[shading=ball, ball color=black!90] (3,1.5) circle (0.25em);
\end{tikzpicture}
\end{document}
Best Answer
If you want to specify the length you can use
++
. So, if you to draw an arrow that is3cm
long use++(3.0cm,0)
as shown in the red arrow.If your desire is to only draw fixed length arrows and place nodes following the arrows, let
tikz
figure out the location of the nodes by usingnode
(not\node
) as part of the\draw
(as opposed to a separate\node
). Be careful to start the drawing from one end of the node (below I usedeast
). Otherwise the center of thenode
is used.Notes:
Code: