Search code examples
rlatexshinymathjax

R shiny MathJax Alignment issue


I have a number of rows of equations in my shiny app which I want to align by their equal sign but can't seem to get the align function to work properly. The code I have is as follows.

p("$$\\begin{align}
     \\ x^2 &=  \\text{Chi-Squared}
      \\ sum &= \\text{summation}
      \\ o &=  \\text{the observed values}
      \\ e &=  \\text{the expected values}
      \\end{align}$$")

This doesn't work though and I can't figure out how to align them properly. Any help would be greatly appreciated


Solution

  • You have not terminated alignment rows. You need to add \\\\ at the end of each row (except the last):

    p("$$\\begin{align}
         \\ x^2 &=  \\text{Chi-Squared} \\\\
         \\ sum &= \\text{summation} \\\\
         \\ o &=  \\text{the observed values} \\\\
         \\ e &=  \\text{the expected values}
         \\end{align}$$")