3

In the following screenshot,

enter image description here

there are some imprecisions on the horizontal part of the arrow that I made using \xrightarrow, which is even highlightable on my pdf viewer. Note that this is also visible in the screenshots on \Rightarrow with text above it. Is there a way around this? Why would the implementation \xrightarrow do such a thing? I ran the following in Overleaf (pdflatex)

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsmath} \newcommand{\isoto}{\xrightarrow{\sim}} % ``isomorphism to'' \let.! % ! is negative space command, so I replace \newcommand{\twoto}{\raisebox{.56ex}{$;\xrightarrow{,,,,}$}\hspace{-11.85pt}\raisebox{-.56ex}{$\xrightarrow{,,,,};$}} % 11/4/21

\begin{document}

$$f: X\to Y, X \isoto Y, X \twoto Y$$

\end{document}

which produces

enter image description here

where the \xrightarrow has noticeably thicker spots compared to \to.

D.R
  • 771
  • 1
    To be able to diagnose this accurately, it's necessary to know what packages and fonts are being used, and possibly also the engine (pdflatex, xelatex, etc.) and imaging software (Acrobat or other pdf-reader/printer). A compact, compilable example that demonstrates the problem would give us the best chance. – barbara beeton Nov 29 '21 at 01:38
  • 1
    Sure, xrightarrow works by printing several partially-overlapping characters (or similar), it's more the printer/renderer's fault for making overlapped lines bolder. Wouldn't happen with an infinite-precision printer? – user202729 Nov 29 '21 at 04:59
  • 1
    There's also some solutions to change the amount of backing, but as long as xrightarrow use only repeated dashes it's not possible to fix in general. https://tex.stackexchange.com/questions/262617/issue-with-xrightarrow – user202729 Nov 29 '21 at 05:40
  • (answers using TikZ to draw the arrows or use two passes are also interesting, but may not be given the full amount of the bounty.) – user202729 Jan 24 '23 at 10:53
  • 1
    The pdfmsym package has \xvarrightarrow which should print a smoother looking line. But the arrow head is a different style than \xrightarrow's (I'm adding this as a comment because of this last point, I'm not sure if it fixes the issue OP or the bountier raise) – Slurp Jan 24 '23 at 13:50
  • @Slurp I think alternative solutions are always welcome (such as solutions for a different TeX format than that the questioner asked), so no problem. – user202729 Jan 26 '23 at 15:06
  • @Slurp If you don't want to, consider posting on math mode - How to put something at the top of the \longrightarrow? - TeX - LaTeX Stack Exchange then? Looks like there isn't any existing answer with that approach there. – user202729 Jan 31 '23 at 14:55

1 Answers1

5

Here is a possibility that gives you the full power of tikz-cd to create your arrows. A macro \myxarrow is defined that takes one required argument and one optional argument.

\myxarrow[<length>]{<tikzcd arrow commands>}

The default length is 1.2em but of course you can set that however you like. Note that this solution does not stretch the arrow automatically.

enter image description here

Several examples appear in the code below. The top example is \xrightarrow{\sim}, which has the overlapping problem you described, but also (in my opinion) places the \sim to high. I prefer the vertical spacing provided by tikzcd.

\documentclass{article}

\usepackage{amsmath, tikz-cd}

\newcommand{\myxarrow}[2][1.2em]{\begin{tikzcd}[cramped, ampersand replacement=&amp;, outer sep=0pt, column sep=#1]{}#2&amp;{}\end{tikzcd}}

\begin{document}

\begin{align} f&\colon X\xrightarrow{\sim} Y\qquad\textup{(using \texttt{\textbackslash xrightarrow)}}\ f&\colon X\myxarrow{\arrow[r,"\sim"]} Y\ f&\colon X\myxarrow[2em]{\arrow[r,"\sim"']} Y\ f&\colon X\myxarrow{\arrow[r, shift left]\arrow[r, shift right]} Y\ f&\colon X\myxarrow{\arrow[r, shift left=1.5pt]\arrow[from=r, shift left=1.5pt]} Y\ f&\colon X\myxarrow[3em]{\arrow[r, red, text=blue, "\mathrm{text}", hook, two heads, bend right, shift left]} Y\ \end{align}

\end{document}

Sandy G
  • 42,558