TransWikia.com

How can I type a newline using the LaTeX Graphviz package?

TeX - LaTeX Asked by SOFe on January 19, 2021

I am using the Graphviz package (usepackage[pdf]{graphviz}) for my LaTeX document.

I am unable to break lines in my nodes.

My code:

digraph{contract}{
    rankdir = "LR";
    computeSumParam0[label = "computeSum: n param #0"];
}

This renders the characters n on the PDF literally.

If I instead use n, LaTeX fails to compile because the command n does not exist.

2 Answers

You can use noexpandn, or wrap it in a macro for better clarity:

documentclass{article}
usepackage[pdf]{graphviz}

begin{document}

digraph{contract}{
    rankdir = "LR";
    computeSumParam0[label = "computeSum: noexpandn param #0"];
}

end{document}

or

documentclass{article}
usepackage[pdf]{graphviz}

newcommand{gvnewline}{noexpandn}

begin{document}

digraph{contract}{
    rankdir = "LR";
    computeSumParam0[label = "computeSum: gvnewline param #0"];
}

end{document}

enter image description here

Correct answer by egreg on January 19, 2021

Just create a new line in the label text!

digraph{contract}{
 rankdir="LR";
 computeSumParam0[label="computeSum:
                         param #0"];
  }

Answered by gigiair on January 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP