Graphics, Figures & TablesArrow coordinates

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
bstex
Posts: 69
Joined: Mon Oct 23, 2017 10:22 am

Arrow coordinates

Post by bstex »

Hi,
i'm having this:
Screen Shot 2018-03-31 at 19.16.56.png
Screen Shot 2018-03-31 at 19.16.56.png (8.59 KiB) Viewed 1764 times
and I would like to raise the arrow, so it is vertically center with the text.
Can that happen without the \raisebox command?
Also, how can I modify the tikz code of the arrow, so it automatically puts a blank space after every arrow I insert in my code with the \myArrow command? I want this because, as you see, the letter B is very close to the arrow tip.

My MWE:

Code: Select all

\documentclass{book}
\usepackage{tikz}
\usepackage{chemfig}
\newcommand{\myArrow}{\tikz {\draw[semithick] [-{Straight Barb[angle=60:1.5pt 3]}] (0,0) -- ++ (0.4,0);}}

\begin{document}
A \myArrow B
\end{document}
Thank you.

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10343
Joined: Mon Mar 10, 2008 9:44 pm

Arrow coordinates

Post by Stefan Kottwitz »

Ho about this:

Code: Select all

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{chemfig}
\newcommand{\myArrow}[2]{\tikz[baseline=(A.base)] {%
  \node (A) {#1};
  \node (B) [right =0.4 of A] {#2};
  \draw[semithick] [-{Straight Barb[angle=60:1.5pt 3]}] (A) -- (B);}}
 
\begin{document}
\myArrow{X}{Y}
\end{document}
Stefan
LaTeX.org admin
Post Reply