I`m trying to input the following formula in latex:

enter image description here

So far I came up with:

$Pr(Classe_i | Objeto) * Pr(Objeto) * IOU^{truth \_pred}= Pr(Classe_i)* IOU^{truth} \_{pred}$

But truth and pred end up side by side and not on a stack. How can I fix it?

  • What is this supposed to represent? – Werner Mar 21 '18 at 21:11
  • You should definitely be writing _, not \_, to create subscripts in math mode. – Mico Mar 22 '18 at 0:52



The \mathrm makes the letters upright.

  • It did work! is there also some trick to make it all be outputed in a single line? – vfbsilva Mar 21 '18 at 21:14
  • 1
    If you want to have it inline but not broken over lines, you can put it in a box to accomplish that (just search on this site to find an example for this). Since this equation is rather long, I would recommend typesetting it in display mode (e.g. with \[ and \] around it instead of $ and $. However I would recommend you read a beginner's guide to LaTeX and typesetting math in it to learn the basics. – schtandard Mar 21 '18 at 21:36
  • You'll have issues when using spaces together with \mathrm. – Werner Mar 21 '18 at 22:31
  • @Werner, depending on what you want to achieve, those "issues" can be regarded a feature. In indices I usually still want math spacing rules to apply, even when I want to use an upright font to indicate that the index denotes a word (like i for initial) rather than a variable (that may be called i), thus \mathrm is almost always the right choice for me. You are of course right that one should be aware that this command does not switch to text mode. – schtandard Mar 21 '18 at 23:31

If what you're typing is text in math mode, use \textup - it ensures its contents is dislpayed as upright text, even if the prevailing font is not upright, like italics (the case within some theorem environments). For a super-/sub-script, use ^ and _; this will ensure placement high/low to the right of an object:

enter image description here





  \Prob{\textup{Class}_i \mid \textup{Object}} \times
    \Prob{\text{Object}} \times
  = \Prob{\textup{Class}_i} \times

  • 1
    Never a good advise to use \text in this context. If the op uses this in an italic context the output would be italic, which is obviously not correct here. Sadly there is a lot of users who do not know when to use \text and when not to. I would probably have used \textup or even \textnormal. Yes this solution works in this case, but does not in all cases – daleif Mar 21 '18 at 21:38
  • 1
    @daleif: Oh my, I'm switching that to \textup, from now on... – Werner Mar 21 '18 at 22:28
  • This is a clear case for \mathrm. – egreg Mar 22 '18 at 7:31

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.