Hi All,
I recently learned that with root, you can export tikz files from you canvasses, which is great! Now I’m including it in my latex file and I find that when I make the image smaller or bigger, the text size changes as well. I was actually not expecting this, since I was under the assumption that if you include a tikz image, you can resize it without affecting the text.
What is great, is that the font of all the text in the image is exactly the font that I use for my latex document, so that seems to work. I was wondering if anyone has the same experience, or maybe someone knows if I’m doing something wrong, or if my expectations are wrong
This is how I include the image in latex:
\begin{figure}
\centering
\scalebox{0.5}{\input{./figures/rawClusters_Ag.tex}}
\caption{Image ({hpx.tex}) generated thanks to {TTeXDump}}
\end{figure}
And I make the plots like this (I do not include all the code here because it is rather big…)
// This is where all the histos are made in the same way
TH1D *allMyHistos(unsigned int metal, unsigned int color, unsigned int nColors, bool clusters, bool strips){
TH1D *myHist = (TH1D*)allMyFiles->Get("h1");
myHist->SetStats(false);
// Titles
gStyle->SetOptTitle(0);
//myHist->GetXaxis()->SetTitleFont(132);
//myHist->GetYaxis()->SetTitleFont(132);
//myHist->GetXaxis()->SetLabelFont(132);
//myHist->GetYaxis()->SetLabelFont(132);
//myHist->GetXaxis()->SetTitleSize(0.045);
//myHist->GetYaxis()->SetTitleSize(0.045);
//myHist->GetXaxis()->SetLabelSize(0.045);
//myHist->GetYaxis()->SetLabelSize(0.045);
myHist->GetXaxis()->SetTitle("Vcth [dac]");
if(clusters) myHist->GetYaxis()->SetTitle("Clusters/Event");
else myHist->GetYaxis()->SetTitle("Hits/Event");
// Axes ranges
myHist->GetYaxis()->SetRangeUser(1e-8,1e2);
myHist->GetXaxis()->SetRangeUser(88,122);
// Line width
//myHist->SetLineWidth(2);
// Colors for the markers and lines
if(nColors==4) myHist->SetMarkerColor(startColorsFour[metal]+color), myHist->SetLineColor(startColorsFour[metal]+color);
else if(nColors==10) myHist->SetMarkerColor(startColorsTen[metal]+color), myHist->SetLineColor(startColorsTen[metal]+color);
else if(nColors==6) myHist->SetMarkerColor(allColors[metal]), myHist->SetLineColor(allColors[metal]);
// Now return the histogram
return myHist;
}//end void stripHisto()
// This is where all the cancasses are made in the same way
TCanvas *allMyCanvasses(bool logScale=true){
TCanvas *myCanvas = new TCanvas();
// Remove a little bit of white space on the sides
myCanvas->SetRightMargin(0.02);
myCanvas->SetTopMargin(0.02);
// Plot in log scale,
if(logScale) myCanvas->SetLogy();
myCanvas->SetTicks();
myCanvas->SetGrid();
// Return the canvas:
return myCanvas;
}//end TCanvas allMyCanvasses()
// This is where all the histos are made in the same way
TLegend *allMyLegends(unsigned int size){
TLegend *myLegend=NULL;
if(size==6) myLegend = new TLegend(0.14,0.65,0.46,0.94);
else if(size==4) myLegend = new TLegend(0.14,0.74,0.46,0.94);
else if(size==10) myLegend = new TLegend(0.14,0.45,0.5,0.94);
else if(size==41) myLegend = new TLegend(0.14,0.74,0.4,0.94);
else if(size==61) myLegend = new TLegend(0.14,0.65,0.65,0.94);
//gStyle->SetLegendFont(132);
//gStyle->SetLegendTextSize(0.045);
return myLegend;
}//end TLegend allMyLegends()
// This is were the different plot are made
void makeNClustersMetals(unsigned int metal){
// TCanvas to draw one, and a TLegend to add entries too
TCanvas *c0 = allMyCanvasses();
TLegend *l0 = allMyLegends(4);
// Draw options for in the loop
unsigned int colorUpdater=0;
for (unsigned int iSensor=0; iSensor<nSensors; iSensor++){
for (unsigned int iCbc=0; iCbc<nCbcs; iCbc++) {
if(fileExists(sensorFileName("clusters", "nClusters", allMeasurements[metal], iSensor, iCbc))){
allMyFiles = new TFile(sensorFileName("clusters", "nClusters", allMeasurements[metal], iSensor, iCbc), "READ");
TH1D *plot = allMyHistos(metal, colorUpdater, 4, true, false);
if(iCbc==0 && iSensor==0) plot->Draw();
else plot->Draw("same");
//l0->AddEntry(plot, Form("%s, s%dc%d", allLegends[metal], iSensor, iCbc), "l");
l0->AddEntry(plot, Form("Sensor %d, CBC %d", iSensor, iCbc), "l");
++colorUpdater;
}else{
cout << MAGENTA << sensorFileName("clusters", "nClusters", allMeasurements[metal], iSensor, iCbc) << " does not exists!" << RESET << endl;
}//end if fileExists()
}//end for iCbc
}//end for iSensor
l0->Draw();
c0->SaveAs(totalFileName("rawClusters", allMeasurements[metal]));
c0->SaveAs(totalFileNamePDF("rawClusters", allMeasurements[metal]));
// Let's see if we can make a tikz file :)
gStyle->SetPaperSize(25., 17.6);
gPad->Print(totalFileNameTIKZ("rawClusters", allMeasurements[metal]));
delete c0;
}//end void makeNClustersMetals()
Cheers,
Nikkie
_ROOT Version: 6.14/06
_Platform: CentOS 7 (@cern)
_Compiler: g++