TransWikia.com

How can you change te arrow tip 'style'

TeX - LaTeX Asked by Armando Rosas on August 3, 2021

I’m working on overleaf and I’m trying to duplicate this diagramenter image description here

But I can’t find any way to obtain the upper arrow tip style or even match the lengths.
This is the closest code i obtained so far:begin{align*} Co&ng(Lambda)longleftrightarrowCon{Lambda} &equivlongleftrightarrowmathcal{C} end{align*}
but it gives me this
enter image description here

One Answer

TikZ is the way to go there:

documentclass{article}
usepackage{tikz}
usetikzlibrary{arrows.meta}
usepackage{amsmath}
usepackage{amssymb}
begin{document}
begin{equation} 
begin{gathered}
mathrm{Cong}(Lambda) tikz[baseline=-0.75ex]draw[{Latex[length=3pt]}-{Latex[length=3pt]}] (0,0) -- +(0.75,0); mathbb C(Lambda) 
equiv tikz[baseline=-0.75ex]draw[{Straight Barb[length=5pt,width=5pt]}-{Straight Barb[length=5pt,width=5pt]}] (0,0) -- +(1.25,0); mathcal C
end{gathered}
end{equation}
end{document}

enter image description here

This uses the tikz command to draw a single inline arrow in each of the two lines. The option baseline=-0.75ex passed to tikz raises the arrow (try leaving it out to see what the effect is!).

Arrows are basically drawn using draw[<->], but instead of < and > I select appropriate arrow tips from the arrows.meta TikZ library: the Latex tip for the first arrow, and the Straight Barb tip for the second (see p. 212 of the humongous TikZ manual for more information and more arrow tips). Each arrow tip also gets some options passed to it to control its length and width; this also makes it necessary to enclose the whole tip specification in braces, so you end up with specifications like {Latex[length=3pt]}-{Latex[length=3pt]} --- looks frightening at first glance, but it really just means "a double-ended arrow with Latex tips of length 3pt on either side, please".

The rest is self-explanatory, I hope. You can make the arrows longer (or shorter) by changing adjusting the distance to which they're drawn, e.g. from (0,0) -- +(0.75,0) (that's 0.75cm) for the first to something different. If you want to raise or lower them, adjust the baseline, as described above. To change the tips, adjust their options, or pass new options to them.

If you need arrows like these more than once, it would probably be a good idea to define appropriate arrow tips and then use those throughout, or (better yet) define commands for the arrows themselves.

Finally -- just to give a few more tips --, the gathered environment is used here to have both lines of the equation centered, and mathrm is used to typeset "Cong" using an upright font rather than the default italic. (Also, to typeset multi-letter identifiers and names in math mode, it's best to use mathit, e.g. mathit{Cong}; writing just Cong typesets the individual letters in a way that's appropriate for the product of single-letter variables, rather than a single multi-letter variable.)

EDIT: here's a snippet where both arrows are defined as new commands instead:

documentclass{article}
usepackage{tikz}
usetikzlibrary{arrows.meta}
usepackage{amsmath}
usepackage{amssymb}
DeclareMathOperator{arrowOne}{tikz[baseline=-0.75ex]draw[{Latex[length=3pt]}-{Latex[length=3pt]}] (0,0) -- +(0.75,0);}
DeclareMathOperator{arrowTwo}{tikz[baseline=-0.75ex]draw[{Straight Barb[length=5pt,width=5pt]}-{Straight Barb[length=5pt,width=5pt]}] (0,0) -- +(1.25,0);}
begin{document}
begin{equation} 
begin{gathered}
mathrm{Cong}(Lambda) arrowOne mathbb C(Lambda) 
equiv arrowTwo mathcal C
end{gathered}
end{equation}
end{document}

I've called them arrowOne and arrowTwo, for lack of a better name; functionally they're identical to the above. Using DeclareMathOperator will also ensure correct spacing, so there's no need to manually use anymore here. (In principle you could also use mathop directly for this, but DeclareMathOperator is preferred; see What is the difference of mathop, operatorname and DeclareMathOperator?).

To define "one-sided" arrows, just leave out either of the arrow tips. If you write draw[{Latex[length=3pt]}-], for instance, TikZ will only draw the left tip, giving you a "come-from" kind of arrow. If you need the vertical bar that mapsto has, you can just add a second draw command to the tikz invocation:

documentclass{article}
usepackage{tikz}
usetikzlibrary{arrows.meta}
usepackage{amsmath}
DeclareMathOperator{comefrom}{tikz[baseline=-0.5ex]{draw[{Latex[length=3pt]}-] (0,0) -- +(0.75,0);draw (0.75,0.05) -- +(0,-0.1);}}
begin{document}
begin{equation} 
x comefrom y
end{equation}
end{document}

enter image description here

You'll probably want to play around with baseline etc. there; it may also be worth putting rounded caps on the lines drawn there, rather than square ones. In any case, the only real caveat here is that since you've got two draw commands, you'll have to wrap them both in braces so that tikz will in fact see and interpret both.

I hope this helps!

Correct answer by chsk on August 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP