# Problem with \`println()\` and \`display()\`, \`display()\` can't display line breaks

**URL:** https://discourse.julialang.org/t/problem-with-println-and-display-display-cant-display-line-breaks/68762
**Category:** General Usage
**Tags:** notebooks
**Created:** [September 25, 2021, 8:57pm UTC](https://discourse.julialang.org/t/problem-with-println-and-display-display-cant-display-line-breaks/68762 "2021-09-25T20:57:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)
#### Post date: [September 25, 2021, 8:57pm UTC](https://discourse.julialang.org/t/problem-with-println-and-display-display-cant-display-line-breaks/68762/1 "2021-09-25T20:57:15Z")

</div>

I have a script that analyses some parameters and prints the result (in a Julia notebook). This includes both text messages and plots. I have problem finding a print format which preserved the order things are printed (like `display()`), but can print strings sensibly (like `println()`).

E.g. if I only use `display()`:

```julia
display("Text Message 1")
display("\n\n")
display(plot(x->x,label="Plot 1"))
display("More Message 2")

```

then strings are displayed weirdly. Even worse, I cannot properly add linebreaks (useful to break up the information, making it less dense to read through).  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/7/67292cfaa062313fdecd4e20f30c284a4d83625f.png)

Instead, I can display text using `println()`, which is good because the strings are displayed properly (and the linebreaks especially). However, this does not preserve the order with which things are printed, especially with regards to the plot:

```julia
println("Text Message 1")
println("\n\n")
display(plot(x->x,label="Plot 1"))
println("More Message 2")

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/b/3b08a5ddf5b28575033f289d97898c3a0bcbe4c8.png)

So, is there some functionality where I can display strings properly, but also be sure in which order the stuff I print appears?

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [September 25, 2021, 8:58pm UTC](https://discourse.julialang.org/t/problem-with-println-and-display-display-cant-display-line-breaks/68762/2 "2021-09-25T20:58:54Z")

</div>

Not sure if it works in Jupyter, but try `display(Text("foo\nbar\nbaz"))`.

---

<div class="post-metadata">

### Author: ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)
#### Post date: [September 26, 2021, 8:57am UTC](https://discourse.julialang.org/t/problem-with-println-and-display-display-cant-display-line-breaks/68762/3 "2021-09-26T08:57:51Z")

</div>

> [@pfitzseb](#):
>
> display(Text(“foo\nbar\nbaz”))

I can confirm that it works

```julia
display(Text("Text Message 1"))
display(Text("\n\n"))
display(plot(x->x,label="Plot 1"))
display(Text("More Message 2"))

```

![image](https://global.discourse-cdn.com/julialang/original/3X/5/4/54588adaad16744bdfe7636e34b892d72809923c.png)

Thanks for the help 🙂
