Root Latex

Dear experts,

I want to print the plus/minus mathematical symbol directly on my screen (out of a canvas) by using this small code:

void ratio() {

cout << hist->GetBinContent(1) << “#pm” << error<<endl;

}

but instead it prints the string: #pm.

The examples that I saw are using canvas. Do you know I can do this is easily?

Regards

This is the TLatex syntax. It works for the graphics output only. Not for the terminal output.

Dear couet,

it is not possible then.

Thank you for your answer.

Regards

In C++ you can use Unicode characters, for plus-minus signs it is cout << "\u00B1" << endl;
Problem might be with root interpreter, as far as I see, in root 5.34/30 with Cint result is following:

root [0] cout << "\u00B1" << endl; u00B1
in root-6.03/03 with Cling

root [0] cout << "\u00B1" << endl; ±

To look for a unified character you can go here:
fileformat.info/info/unicode/char/search.htm

Dear rlalik,

thank you for your answer.
Actually I’m using root 5 and it’s not working.

Regards

You can try to put your code in a macro and use AClic.

file pm.C:

#include <iostream>

void pm(){
   printf("\u00B1\n");
}
root [0] .L pm.C+ 
Info in <TMacOSXSystem::ACLiC>: creating shared library /Users/couet/roottest/./pm_C.so
root [1] pm()
±
root [2] 

Dear Rlalik and Couet,

Thank you for your help. I switched to root 6 and it’s working.

Regards