Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

LaTeX-compatible plugin

Options

Comments

  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,161 Mod ✭✭✭✭Jonathan


    Big +1

    Writing equations without it is a pain .


  • Registered Users Posts: 29,509 ✭✭✭✭randylonghorn


    Such an excellent thread title!! :D



    /runs



    Sorry, guys, but irresistible!


  • Closed Accounts Posts: 2,208 ✭✭✭Économiste Monétaire


    +1


  • Closed Accounts Posts: 2,479 ✭✭✭Conor


    LaTeX-style markup is now available via the [NOPARSE][LATEX][/NOPARSE] tag.

    Examples:

    Code|Result
    [NOPARSE][LATEX]e = mc^2[/LATEX][/NOPARSE]|[LATEX]e = mc^2[/LATEX]
    [NOPARSE][LATEX]i\hbar\frac{\partial}{\partial t} \Psi(r,\,t) = \hat H \Psi(r,\,t)[/LATEX][/NOPARSE]|[LATEX]i\hbar\frac{\partial}{\partial t} \Psi(r,\,t) = \hat H \Psi(r,\,t)[/LATEX]


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,161 Mod ✭✭✭✭Jonathan


    We should request features more often :P


  • Advertisement
  • Closed Accounts Posts: 2,479 ✭✭✭Conor


    Jonathan wrote: »
    We should request features more often :P

    I'm sure you can use the new tag to show a formula modeling the relationship between the rate of feature requests and the rate of features implemented. :)

    I'll get you started:
    • The rate of feature requests is related to the number of users.
    • The amount of time available to implement features is inversely related to the number of users on the site.
    • The probability of any given feature being implemented is related to the amount of time available to implement it and inversely related to how cranky the developers are.
    • The crankiness of the developers is related to
      • The number of annoying features yet to be implemented.
      • How long it has been since they've been fed with coffee and/or cake.


    And... go! :D


  • Registered Users Posts: 8,452 ✭✭✭Time Magazine


    Thanks Conor, but there's a slight problem: LaTeX can't add.

    (And by that I mean it's ignoring plus signs (+) and I don't think there's a \plus command.)


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,161 Mod ✭✭✭✭Jonathan


    Also the plugin doesn't seem to allow line breaking..


  • Closed Accounts Posts: 2,479 ✭✭✭Conor


    Thanks Conor, but there's a slight problem: LaTeX can't add.

    (And by that I mean it's ignoring plus signs (+) and I don't think there's a \plus command.)

    That's because all the tag does is find [NOPARSE][LATEX]foo[/LATEX][/NOPARSE] and replace it with <img src="http://www.mathtran.org/cgi-bin/mathtran?tex=foo&quot; />

    Since + is a reserved character in URLs, it's getting translated into a space.

    vBulletin's tag system only allows dumb find-and-replace, I can't do any manipulation of the data in the tags without writing a plugin. I'll try and figure out a hack with some JavaScript, but I mightn't get to it today.
    Jonathan wrote: »
    Also the plugin doesn't seem to allow line breaking..

    Nothing I can do about that I'm afraid for the same reasons as above.


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,161 Mod ✭✭✭✭Jonathan


    Use %2B as a plus.
    [latex]1 %2B 5=6[/latex]


  • Advertisement
  • Closed Accounts Posts: 2,479 ✭✭✭Conor


    Yeah, that's doable, but I'd like to escape it properly.


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,161 Mod ✭✭✭✭Jonathan


    It possible to do a regex replace on just the latex tag so it doesn't kill the servers?


    EDIT:
    /facepalm
    Even easier. Just urlencode the tag.


  • Closed Accounts Posts: 2,479 ✭✭✭Conor


    I can't do it server-side without implementing the tag by hand (which I'm not going to do).

    I'll write a little piece of JS to diddle the URL but I have to jump through a hoop or two. I can't just write
    document.write('<img src="http://..."' + encodeURIComponent(latex) + '" />');
    

    for fairly obvious reasons!


  • Closed Accounts Posts: 2,479 ✭✭✭Conor


    Take 2:

    Code|Result
    [NOPARSE][LATEX]a + b[/LATEX][/NOPARSE]|[LATEX]a + b[/LATEX]
    [NOPARSE][LATEX]e = mc^2[/LATEX][/NOPARSE]|[LATEX]e = mc^2[/LATEX]
    [NOPARSE][LATEX]i\hbar\frac{\partial}{\partial t} \Psi(r,\,t) = \hat H \Psi(r,\,t)[/LATEX][/NOPARSE]|[LATEX]i\hbar\frac{\partial}{\partial t} \Psi(r,\,t) = \hat H \Psi(r,\,t)[/LATEX]


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,161 Mod ✭✭✭✭Jonathan


    How did you do it in the end?


  • Closed Accounts Posts: 2,479 ✭✭✭Conor


    Jonathan wrote: »
    How did you do it in the end?

    [NOPARSE][LATEX]EQUATION GOES HERE[/LATEX][/NOPARSE]

    produces:

    [HTML]
    <img src="http://www.mathtran.org/cgi-bin/mathtran?tex=EQUATION GOES HERE" class="latex-equation" />
    <script type="text/javascript">
    var latex_equations = YAHOO.util.Dom.getElementsByClassName('latex-equation', 'img');
    for (var i = 0; i < latex_equations.length; i++) {
    var parts = latex_equations.src.split('tex=', 2);
    latex_equations.src = parts[0] + 'tex=' + encodeURIComponent(decodeURIComponent(parts[1]).replace(/<br \/>/g, ""));
    YAHOO.util.Dom.replaceClass(latex_equations, 'latex-equation', 'latex-equation-escaped');
    }
    </script>
    [/HTML]

    It's a nasty horrible bodge.


  • Registered Users Posts: 5,083 ✭✭✭RoundTower


    on another vBulletin forum I was told there is a LaTex plugin available for vB but it's a bitch to install/maintain.

    This looks relatively straightforward in comparison. I can't speak for just how bad of a horrible bodge it is, but is it straightforward to do what you did?


  • Closed Accounts Posts: 2,479 ✭✭✭Conor


    RoundTower wrote: »
    on another vBulletin forum I was told there is a LaTex plugin available for vB but it's a bitch to install/maintain.

    TBH, the first LaTeX plugin I saw involved installing LaTeX on the server and running the tag contents through it and producing images from it. The idea of allowing users to run content through an external program fills me with horror so I backed off and looked for another solution.

    I then remembered that a friend of mine (Professor Fink) has a LaTeX plugin on his blog. I ripped that off, tweaked it and there you have it.
    RoundTower wrote: »
    This looks relatively straightforward in comparison. I can't speak for just how bad of a horrible bodge it is, but is it straightforward to do what you did?

    Well, it does rely on the good will of mathtran.org and their willingness to continue to generate images for us.

    Other than that, it's easy enough to implement. Anyone who has implemented a custom vBulletin tag should be able to replicate what I've done with very little hassle once they see my post above.


Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.

Advertisement