# Adding newline in legend entry

**URL:** <https://root-forum.cern.ch/t/adding-newline-in-legend-entry/49107>\
**Category:** Newbie\
**Tags:** hist, root\
**Created:** [March 9, 2022, 7:55pm UTC](https://root-forum.cern.ch/t/adding-newline-in-legend-entry/49107 "2022-03-09T19:55:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Voldemort](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/voldemort/32/28433_2.png) [@Voldemort](https://root-forum.cern.ch/u/Voldemort)\
**Post date:** [March 9, 2022, 7:55pm UTC](https://root-forum.cern.ch/t/adding-newline-in-legend-entry/49107/1 "2022-03-09T19:55:34Z")

</div>

I’m trying to start a new line but it doesn’t seem to be working.  
Here’s what I want my legend to look like:

> with Geometry  
> Entries 3

```auto
.....
std::stringstream result_stringstream;
result_stringstream << "with Geometry" << "\nEntries " << totalTrig;
//result_stringstream << "with Geometry" << endl << "Entries " << totalTrig;
string result_string = result_stringstream.str();
const char* result = result_string.c_str();
....
t1->AddEntry( nhit, result, “l”);
.....

```

so the **\n** just gives me all on the same line:

> with Geometry Entries 3

and **endl** gives all on the same line:

> with GeometryEntries 3

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [March 9, 2022, 8:02pm UTC](https://root-forum.cern.ch/t/adding-newline-in-legend-entry/49107/2 "2022-03-09T20:02:49Z")

</div>

Try with:  
`result_stringstream << "#splitline{with Geometry}{Entries " << totalTrig << "}";`

---

<div class="post-metadata">

**Author:** ![Voldemort](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/voldemort/32/28433_2.png) [@Voldemort](https://root-forum.cern.ch/u/Voldemort)\
**Post date:** [March 9, 2022, 9:39pm UTC](https://root-forum.cern.ch/t/adding-newline-in-legend-entry/49107/3 "2022-03-09T21:39:51Z")

</div>

Oh my goodness! That did the trick 😁 Thank you @Wile_E_Coyote !
