Add newline to LaTeXString equation

Nathan_Boyer
Thu, 23 Feb 2023 20:31:13 +0000
Visualization

Hello, I have a LaTeXString which is too long to fit in one page-width. How can I add a line break to the equation so that it fits? I tried to add a \\ in the middle, but that didn’t change the rendering at all.

julia> s = L"$\Delta\epsilon_{peqk} = \frac{\sqrt{2}}{3} \cdot \left( \left( \Delta\epsilon_{p11k} - \Delta\epsilon_{p22k} \right)^{2} + \left( \Delta\epsilon_{p22k} - \Delta\epsilon_{p33k} \right)^{2} + \left( \Delta\epsilon_{p33k} - \Delta\epsilon_{p11k} \right)^{2} + 1.5 \cdot \left( \Delta\epsilon_{p12k}^{2} + \Delta\epsilon_{p23k}^{2} + \Delta\epsilon_{p31k}^{2} \right) \right)^{0.5}$";

julia> ss = LaTeXString(replace(s, "+ 1.5" => "\\\\ + 1.5"; count=1))
L"$\Delta\epsilon_{peqk} = \frac{\sqrt{2}}{3} \cdot \left( \left( \Delta\epsilon_{p11k} - \Delta\epsilon_{p22k} \right)^{2} + \left( \Delta\epsilon_{p22k} - \Delta\epsilon_{p33k} \right)^{2} + \left( \Delta\epsilon_{p33k} - \Delta\epsilon_{p11k} \right)^{2} \\ + 1.5 \cdot \left( \Delta\epsilon_{p12k}^{2} + \Delta\epsilon_{p23k}^{2} + \Delta\epsilon_{p31k}^{2} \right) \right)^{0.5}$"

julia> render(ss)

Rendered in VSCode:

Rendered to PDF with Weave:

11 posts - 7 participants