text in a math expression

pviton's picture

SWP 6.0.30 on Win10

I'm trying to enter a math display that mixes
math and text:
Pr[A is best]
with "Pr[A" in math, "is best" in text,
and the closing "]" in math.

In SWP5 this is straightforward: enter
"Pr[A" in math, then switch to text and enter
"is best" and then finally switch back to math
for the closing "]". An alternative is to
tag the "is math" as Roman: both versions
seem to display in pdf the same way.

In SWP6 this does not seem to work. While
I can enter the text, previewing just
displays "Pr(A)" which is wrong. Moreover
it does not seem possible to select the text
part ("is best") to try to tag it as Roman (or
anything else) if one thought that that
might help. Trying to type the "is best" in
math and then converting it to text also
does not seem to work.

I'm attaching a sci archive with my attempt.
Is there a way to do this in SWP6?

AttachmentSize
text-in-math.sci60.22 KB
Barry MacKichan's picture

I just tried this with the

I just tried this with the current (not-yet-released) build, and it works, pretty much.

I entered a display and typed 'Pr[A' in math mode, switched to text mode and typed 'is best', switched back to math mode and typed ']'. The one problem I saw was that I couldn't start the text mode part with a space. I had to put the cursor in the text and press left arrow until the cursor was just before the 'i'. Then I could type a space.

So,

  1. It will work in version 6.0.31, pretty much as it works in 5.5.

  2. The PDF is correct and attached.

  3. A partial screen shot of the document is attached, as is the full document. It should display correctly in 6.0.30. You should be able to copy it into your existing document, if needed.

  4. In MathML, the text ' is best' is actually in an <mtext> object inside the math expression. As such the text is a weird animal, part math and part text, which accounts for the strange behavior around the first space.

  5. If you fuss around with the math expression enough, it is possible that there is a line break in the .sci file. Generally a line break or space within MathML is harmless, but this one occurs at the end of the <mtext> which is one case where the space is significant. It showed up as extra space between 'best' and ']'. Retyping the 't]' part of the expression fixed it. More of the weirdness.

  6. I consider both of those weirdnesses to be bugs.

--Barry

jm's picture

Well, it can be done - see

Well, it can be done - see the attached file. How I did it was to copy a display from a paper of mine that had some non-math text in a display, paste it into your document, copied some math that included the non-math text from that, pasted it into the expression Pr[A], edited the non-math text to "is best" and deleted the surrounding superfluous math. (The difference between eqs (2) and (3) is that the former has unpaired square brackets, the latter paired ones because I was checking whether this made a difference.)

What I don't know is how I originally created the non-math text in the display. Possibly it was imported from SWP 5.5.

If all you want is an instance of this for something you are writing, you could adopt my procedure. If you want to understand how to do this without copying an example, you could check the differences in the source file.

pviton's picture

Thanks very much for this!

Thanks very much for this! I'm still trying to get it to work, though so far there have been problems. I'll keep trying.

Following your suggestion I looked at the source. In your successful versions, the "is best" is tagged as 'mtext', while in mine it isn't. Perhaps SWP6 should provide an mtext tag in the tags drop-down to help with this? As far as I can tell, there currently isn't a way to do this.

(I also tried to insert the ... pair by hand in source view but that didn't help).

Barry MacKichan's picture

I just ran version 6.0.30,

I just ran version 6.0.30, and tried what I described above. It did not work. Apparently I made that change after version 6.0.30 was released.

Until we release the next version, the best strategy for you is to replace a string of <mi>...x...</mi> with a single <mtext>...</mtext> in source view. You can copy the displayed result and make a fragment of it. I just did this in 6.0.30 and it worked. Just be sure that when you copy the mtext, you get it all and not just its contents. The easiest way to do this is to put the cursor in the text and click on the <mtext> button that appears on the status bar. If you right click, you will have a choice from a list including "Select" and "Select inner". You should use "Select". Once it is selected you can drag it to the fragments sidebar.

That fragment will insert <mtext>...</mtext> in math. You can change the contents of the <mtext> in the usual way.  If you drop the fragment into text, you actually get a math object containing only the <mtext>. It will be black since the style rules for math in SWP6 say that all math except mtext contents are red.

In the fixed version, if you select part of some mathmatics and convert to text using the math/text button or command, you will get a math expression containing the <mtext> tag rather than two pieces of math before and after some plain text.

--Barry