1

I am trying to compile \xymatrix{A\ar@{\sim>}[r] & B} in LyX and I get the following error message: enter image description here

How can I fix this? The code compiles in ERT, just not in the native xypic mathmode.

Here is a link to MWE.lyx

6
  • \sim is mathmode. Try replacing it for a tilde ~ Commented Sep 19, 2015 at 13:43
  • @JJMDriessen didn't work either. Exactly the same errors.
    – Exterior
    Commented Sep 19, 2015 at 13:48
  • I've added some MWE code in the answer below that doesn't produce the error. Commented Sep 19, 2015 at 14:00
  • @Exterior can you please post an MWE .lyx file? Please read wiki.lyx.org/FAQ/MinimalExample
    – scottkosty
    Commented Sep 19, 2015 at 18:54
  • @scottkosty added a link.
    – Exterior
    Commented Sep 22, 2015 at 11:46

2 Answers 2

2
+50

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.

  1. Go to Insert -> Math -> Macro.
  2. Write \sqarrow instead of \newmacroname.
  3. Then you copy the text \ar@{~>}[r], and paste it directly into the TeX field of the LyX macro.
  4. Finally, in the LyX field of the macro, enter some symbol that resemble the output symbol, such as ~~> 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.

3
  • If you think this is a bug in LyX (or you have an idea for how LyX can do this better), please open a ticket at lyx.org/trac
    – scottkosty
    Commented Sep 26, 2015 at 15:50
  • Actually, this issue is just now being discussed in the lyx-devel mailing list. As for today, there is no convenient way of inserting pure tex code into the LyX math editor.
    – akvilas
    Commented Sep 27, 2015 at 17:15
  • Ah I did not realize that was the same issue. Thanks for pointing that out!
    – scottkosty
    Commented Sep 27, 2015 at 20:08
2

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}

enter image description here

3
  • Ah, now I see that the problem is actually with LyX. If I write the code in ERT then it works, but it won't compile within the native xypic framework. Can you help me solve this?
    – Exterior
    Commented Sep 19, 2015 at 14:08
  • @Exterior. I don't use LyX. Maybe checking out chapter 1 & 2 from this document would help: wiki.lyx.org/uploads/Examples/XY-pic/xypic.pdf Did you include the preview package? Commented Sep 19, 2015 at 14:23
  • Thanks for the suggestion but it seems to be a very specific error. All other arrows and diagrams work well for me... :(
    – Exterior
    Commented Sep 19, 2015 at 18:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .