简体   繁体   中英

Change LaTeX equation font size within `eqnarray` in RMarkdown

I have a latex equation as part of an RMarkdown document that I'm knitting to an HTML file using knitr . I would like to use the LaTeX eqnarray to align the equality signs. However, I would also like to change font sizes from the first equation to the next.

This works, but equality signs are not lined up:

---
title: "Test"
author: "Eric"
date: "5/14/2020"
output: html_document
---

\[
\large a = b \times (c + d)\\
{\small\begin{eqnarray}
a &=& \mathrm{var ~a}\\
b &=& \mathrm{var ~b}\\
c &=& \mathrm{var ~c}
\end{eqnarray}}
\]

The result:

这有效
I tried many different arrangements of brackets and terms. Here is an example that does not work:

---
title: "Test"
author: "Eric"
date: "5/14/2020"
output: html_document
---

#### Try to line up equal signs AND change font sizes (doesn't work)

\[
\begin{eqnarray}
\large a &=& b \times (c + d)\\
{\small
a &=& \mathrm{var ~a}\\
b &=& \mathrm{var ~b}\\
c &=& \mathrm{var ~c}}
\end{eqnarray}
\]

#### Try again (doesn't work):
\[
\begin{eqnarray}
{\large a &=& b \times (c + d)}
{\small
\\a &=& \mathrm{var ~a}\\
b &=& \mathrm{var ~b}\\
c &=& \mathrm{var ~c}}
\end{eqnarray}
\]

How do I line up the equal signs using eqnarray while changing font sizes?

This seems to be what you'd want:

\[
\small
\begin{eqnarray}
{\large a}\ & {\large =} & {\large b \times (c + d)}\\
a &=& \mathrm{var ~a}\\
b &=& \mathrm{var ~b}\\
c &=& \mathrm{var ~c}
\end{eqnarray}
\]

The spacing for the a is a little bit off, which is why I added the \ after it. You might want to fiddle with that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM