Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Bug Latex rendering (another thread)

  1. Apr 28, 2016 #1

    andrewkirk

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    In post #4 of this thread the latex engine seems to go haywire halfway through a 'display math' section delimited by double dollars.

    The same code, with the PF-specific breakouts for in-line tex converted to latex standards, works perfectly in my offline latex engine. Further, to my surprise, when I pasted the PF-style latex code into a code window (lower down in the same post) that renders it correctly (I wasn't expecting it to attempt to render it at all!).

    Does anybody have any idea what's going wrong there?

    Also, it may be a useful observation for future reference that a code window renders latex, and seems to do so better than in the normal part of a post!

    EDIT: The problem is now solved, thanks to Samy and Ibix, so the problem is no longer visible in that post. It was where a superscript of a symbol within the latex code was the letter i enclosed within square brackets [...]. It was interpreting it as an instruction to start italics, rather than taking it literally as written.
     
    Last edited: Apr 28, 2016
  2. jcsd
  3. Apr 28, 2016 #2

    Samy_A

    User Avatar
    Science Advisor
    Homework Helper

    I think your problem is with [x], where x stands for i.
    Adding spaces around the i works: ##[ i ]##.
     
  4. Apr 28, 2016 #3

    Ibix

    User Avatar
    Science Advisor

    You've got an i in square brackets in the maths. I think the forum is reading it as "now start italic text" and breaking the Latex. Since the code tag ignores formatting inside it, it works there.

    Change to \left[ i \right]?
     
  5. Apr 28, 2016 #4

    andrewkirk

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Thank you very much Ibix and Samy. I never would have guessed that the 'start italic' code was still operative within a delimited section of latex code. I've followed your suggestions and it all works nicely now.
     
  6. Apr 28, 2016 #5

    Ibix

    User Avatar
    Science Advisor

    The board software has to be able to handle badly nested tags somehow. In the context of a public forum it can't just throw a compiler error and sulk in the corner until J Random User figures out how he broke the formatting. Unfortunately it doesn't always do the right thing - particularly in this case where you didn't mean to write a tag at all.
     
  7. Apr 28, 2016 #6

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    It's something that would require a lot of code changes to fix. The problem is the execution order: the forum software has no idea about LaTeX. It parses the post, finds a "start italic" command and starts italics. It does not know that $$ has a special meaning, it delivers LaTeX formulas as plain text to the user. On the user side then, MathJax (javascript-based) looks for those dollar signs, takes the (forum-delivered) html text between them and tries to interpret it as LaTeX. That fails, because it does not understand the html codes that the forum put in.

    Adding spaces is the easiest workaround. $$A[ i]$$ -> $$A[ i]$$
     
  8. Apr 28, 2016 #7

    DrGreg

    User Avatar
    Science Advisor
    Gold Member

    I don't suppose it's possible for the forum software to treat LATEX delimiters as if they were a [plain] ... [/plain] pair?
     
  9. Apr 28, 2016 #8

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    It would be possible to modify it, but I doubt the XenForo developers would include that, as MathJax is not part of XenForo.
    @Greg Bernhardt can answer that better.
     
  10. Apr 28, 2016 #9
    The developers won't be interested in this unique request, but I'll add it to my list of custom work to consider.
     
  11. Apr 28, 2016 #10

    andrewkirk

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    It would be useful to add to the forum's latex primer a paragraph saying that the user should make sure that latex code does not contain any symbol strings that match BB codes (and explain why), and link to the page that lists them.

    It would be similar to the section of the primer currently labelled 'Important Bug'. Actually, maybe it would be good to create a section that lists bugs, perhaps together with a few of the most common user errors. It could be called 'Troubleshooting' in the interests of being more optimistic.
     
  12. Apr 29, 2016 #11

    micromass

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2016 Award

    There's a lot of things I want to change in my LaTeX primer, but sadly I don't have the powers to do it anymore. I think only Greg can change those tutorials nowadays.
     
  13. Apr 29, 2016 #12

    ProfuselyQuarky

    User Avatar
    Gold Member
    2016 Award

    What would you change?
     
  14. Apr 29, 2016 #13

    micromass

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2016 Award

    There is many outdated advice from when the old forum software was used, and there is a lot of new stuff with the current forum software that isn't described in the tutorial. For example, the entire paragraph on the "character limit without spaces" needs to be removed. I'll just try to get the code, change it and send it to Greg. He'll upload it then. I'll change the other FAQs too since they're outdated too.
     
  15. May 1, 2016 #14

    andrewkirk

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    I think it would be excellent to update the LaTeX primer. It certainly is a little dated now. Various ideas for useful inclusions have come to me from time to time. Ones that I can remember off the cuff are:

    1. Obviously (because it's most recent) the above issue about making sure the latex code does not inadvertently contain any BB codes.

    2. The great trick that I saw in somebody's post recently for writing raw latex code into a post for people to read, without it getting rendered. That is to change the colour of the delimiters to black (rather than automatic), thereby using the previous bullet point in a constructive way to disrupt the rendering. eg ##\pi##, $$\pi$$

    3. The fact that the standard latex delimiter $ to open and close in-line latex does not work on the forum (presumably to stop latex rendering inadvertently, and unwantedly, when somebody is writing about dollars), and that the simplest replacement is ##.

    4. The neat regular expression that somebody wrote that can in a single editor command (in a suitably competent editing program) convert standard latex to PF-latex by changing all single dollars (but not if they're in a double dollar) to double-hash symbols. I don't have the expression to hand but it could easily be dug up or recreated.

    5. The alternative of, when preparing latex off-line for posting to PF (the only reasonable way to do it for any non-trivial calculations, IMO), using the other standard \( and \) asymmetric delimiters for in-line latex, which can then be converted to the PF-latex asymmetric delimiters [itex] and [/itex] by two very basic search and replace commands, without having to remember the fancy regex command from point 4. This alternative has the additional advantage that, because it does not use regexes, one can do it in any editor, even (Gasp!) Microsoft Notepad.

    6. Showing links to free, open-source latex programs such as TeXmaker, TeXworks, Miktex, MacTex, that people can use both to learn latex, develop proficiency and prepare non-trivial mathematical posts for posting to PF.
     
  16. May 2, 2016 #15

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    Replace (^|[^\\$])\\$([^\\$]|$) by $1##$2.
    Note how both ^ and $ are used in two different contexts.

    Those things can be mentioned somewhere under "advanced", they are certainly not the basics any more.
     
  17. May 3, 2016 #16

    jtbell

    User Avatar

    Staff: Mentor

    Mentors have the ability to add or edit the help pages, and I've started working on the LaTeX primer. Unfortunately, it will take a while to finish the job. I'm basically writing it over from scratch. In our old forum software, the help pages were written the same way as ordinary posts, using BBcode tags for formatting. The current software uses HTML tags for formatting help pages. Greg apparently ran the old help pages through a converter, or maybe he simply copied and pasted the HTML code that the old software generated. The result is very clumsy and hard to work with for editing. Therefore I decided to start from scratch, coding the HTML by hand. You can see the current state of this project at the bottom of the list of "Help/How-To" pages.
     
  18. May 4, 2016 #17

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    You can use the forum itself as BBcode->HTML converter for most things, but there are also many converters available on various websites.

    Writing directly in HTML is more powerful of course.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Latex rendering (another thread)
  1. Another LaTeX bug (Replies: 14)

  2. Rendering LaTeX (Replies: 2)

  3. Latex rendering (Replies: 9)

Loading...