1

I am editing an xymatrix in LyX, and in order to curve some of the edges it requires me to be able to insert /_/ in math mode. However, every time I type that sequence of characters, LyX converts it into /_{/}, which breaks the xymatrix compilation. Is there a way to tell LyX not to add curly braces?

The actual latex output can be verified through View->Source Pane.

Typing Ctrl+L to input raw code does not help in this case as it does not behave as expected in math mode.

I am using Lyx Version 2.1.4

5
  • sounds like something that needs to be brought to the attention of the lyx maintainers. Apr 13, 2016 at 0:46
  • I don't think you can insert custom LaTeX in math mode. We can probably find a workaround though. Can you provide a minimal example .lyx file? I don't use xymatrix so it will be easier to start with this. For now just put /_{/} and I'll know that's the place where you want /_/. For more information, see wiki.lyx.org/FAQ/MinimalExample
    – scottkosty
    Apr 13, 2016 at 3:54
  • Here is minimal example. If you go to View -> Source Pane, you should be able to see that /_/ is formatted as /_{/}.
    – D R
    Apr 13, 2016 at 4:43
  • 1
    @dzhelil thanks for the example. The only workaround I can think of is to put the entire math expression in ERT. So in this example you would put the following $/_/$ in an ERT box. Of course that is not nice but I can't think of a better way. Note for the future that a .lyx file is just text so you can actually just paste it into your question instead of linking to an external file.
    – scottkosty
    Apr 13, 2016 at 7:59
  • @dzhelil I think my answer is the correct one. Do you have any feedback?
    – G.M.
    Apr 27, 2016 at 17:48

3 Answers 3

4

As per http://www.mathematik.uni-marburg.de/~gumm/LyX/xypic/xypic.pdf, in LyX one must use \sp instead of ^ and \sb instead of _.

1
  • Just noting that the cited document can be found in LyX>Help>Specific Manuals. Apr 13, 2016 at 17:04
2

This is not a perfect answer but is a slightly better workaround than putting the whole picture in a TeX environment. Add the following to your preamble (in Document->Settings):

\makeatother
\newcommand{\arup}[1]{\ar@/^/[#1]}
\newcommand{\ardn}[1]{\ar@/_/[#1]}
\makeatletter

(Yes, this combination of \makeatother and \makeatletter is the opposite way round than you may be used to seeing in a preamble. This is because LyX already surrounds the preamble with a \makeatletter / \makeatother pair, but we actually do not want it for these macro definitions, so we have to temporarily turn it back off.)

Now where you would have used something like \ar@/_/[r], instead use \ardn{r}. I suspect you're already aware, but note that the key sequence to produce the braces is a little unintuitive, because LyX usually escapes them for you:

  • {r} gives \{r\} in TeX (which actually gives {r} in the PDF output).
  • \{rspace gives {r} in TeX.

Finally, a half-related tip. If you use xymatrix in LyX documents a lot, it may be worth defining your own macros for the arrows in LyX using insert->math->macro. (You cannot put /_/ in these either, so you still need the premable macros too.) You can then put what you really want in the "TeX" box, but put something visually suggestive in the "LyX" box e.g. \overset{#1}{\curvearrowright}. This can make editing a big matrix a bit less confusing.

2

The XY-pic User's guide says that /_/ is just a short for /:a(-90)/, so I guess you could use something like \ar@/:a(-90)/[r]. \ar@(dr,ur)[r] works too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.