I am trying to compile \xymatrix{A\ar@{\sim>}[r] & B}
in LyX and I get the following error message:
How can I fix this? The code compiles in ERT, just not in the native xypic mathmode.
Here is a link to MWE.lyx
I am trying to compile \xymatrix{A\ar@{\sim>}[r] & B}
in LyX and I get the following error message:
How can I fix this? The code compiles in ERT, just not in the native xypic mathmode.
Here is a link to MWE.lyx
Your problem is that the xypic package requires some special characters (in particular the tilde ~), which is automatically rewritten by the math editor in LyX. It is somewhat cumbersome to make LyX insert a true tilde into the source code.
But this is a case where the LyX "Macro" feature comes in handy.
\sqarrow
instead of \newmacroname
. \ar@{~>}[r]
, and paste it directly into the TeX field of the LyX macro. ~~>
or \rightarrow
.You have now created a macro \sqarrow
for the squiggly arrow, which you can use directly in the LyX math editor.
For the record, LyX rewrites this macro as \global\long\def\sqarrow{\ar@{~>}[r]}
in the LaTeX source code.
The shape input of \xymatrix
in \ar@{shape}[direction]
does not use mathmode and uses its own interpreter to recognize types of arrow shapes. The input is independent of the environment, and works both in textmode and mathmode:
\documentclass{article}
\usepackage[all,cmtip]{xy} % include cmtip or your arrow will be ugly
\begin{document}
\xymatrix{A\ar@{~>}[r] & B}
\begin{equation}
\xymatrix{A\ar@{~>}[r] & B}
\end{equation}
\end{document}
preview
package?
Commented
Sep 19, 2015 at 14:23
\sim
is mathmode. Try replacing it for a tilde~