3

I've been using $$ \nabla $$ on StackExchange to inline multiple math equations with success. I'm switching to pure Latex using Overleaf and have questions.

My goal is to produce a document with some simple left aligned or centered equations. I try the following code, however it has problems:

  1. Font size too small of math equations, changing \documentclass[Xpt]{article} has no effect on math equation font size
  2. Spacing between each equation line is too small. I want to increase the spacing

Can anyone provide suggestions here? I provide some sample code I'm working with:

\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{amsmath}

\begin{document}
\begin{math}
     C_x(...) = \sum_{j=0}^{n_L - 1} (a_j^{(L)} - y_j)^2 \\
     a_j^{(L)} = \sigma(z_j^{(L)}), z_j^{(L)} = \sum_{k=0}^{n_L - 1} (w_{jk}^{(L)} a_k^{(L-1)}) + b_j^{(L)} \\
\end{math}

\end{document}
2
  • 2
    Welcome to tex.se, try \begin{align} instead maybe?
    – JamesT
    Commented Jul 19, 2023 at 15:08
  • 1 is incorrect. The three options 10pt, 11pt and 12pt all affect math as well as text. Commented Jul 19, 2023 at 16:17

2 Answers 2

5

I suggest you display the equations across three lines, rather than just two. To increase the vertical spacing between the rows, append [\jot] to \\.

A suggestion about notation (not implemented in the code below): Would it be ok to replace all instances of (L) and (L-1) with just L and L-1, respectively? Making this change would greatly reduce the high degree of visual clutter.

The code shown below doesn't specify a font size option when executing the \documentclass directive, implying that the default 10pt document font size is employed. If you choose to set 12pt as one of the document class options, the text and math fonts will be increased linearly by 20 percent relative to the default 10pt option.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for `align*` env.

\begin{document}

\begin{align*}
C_x({}\cdot{}) &= \sum_{j=0}^{n_L - 1} \bigl(a_j^{(L)} - y_j \bigr)^2 \\[\jot]
     a_j^{(L)} &= \sigma\bigl(z_j^{(L)}\bigr) \\[\jot]
     z_j^{(L)} &= \sum_{k=0}^{n_L - 1} w_{jk}^{(L)} a_k^{(L-1)} + b_j^{(L)} 
\end{align*}

\end{document}
2
  • I wasn't aware of [\jot] option. I use something like [1mm] instead of that. It seems that [\jot] is standard and automated. Can you explain its logic?
    – C.F.G
    Commented Jul 20, 2023 at 6:02
  • @C.F.G - \jot is a length parameter that's defined by the amsmath package. Its default value is 3pt. Not sure what you mean by [\jot] being "automated"; for sure, if no optional parameter is provided to the \` line-break directive, then nothing special happens. An advantage to specifying \jot` in terms of a standard typographic length (such as pt) instead of mm is that its easier to gauge its effect on the appearance of the math formula.
    – Mico
    Commented Jul 20, 2023 at 8:33
3

How about something like this:

enter image description here

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{align}
     C_x(...) &= \sum_{j=0}^{n_L - 1} (a_j^{(L)} - y_j)^2 \\
     a_j^{(L)} &= \sigma(z_j^{(L)}), z_j^{(L)} = \sum_{k=0}^{n_L - 1} (w_{jk}^{(L)} a_k^{(L-1)}) + b_j^{(L)} 
\end{align}

\end{document}

Using align environment lets you use &= instead of just =, the ampersand (&) makes the equations align at that symbol. The spacing is improved of your original code but perhaps might not be enough, if so please comment.

4
  • \DeclareMathSizes{10}{14}{10}{10} is a very odd setting. Commented Jul 19, 2023 at 16:18
  • @DavidCarlisle I'm not too familiar with having to set math fonts, what would be more appropriate do you think? I have a feeling the last {10} is odd because it is scriptscript size
    – JamesT
    Commented Jul 19, 2023 at 16:32
  • yes you are making script and scriptscript the same size, but I suspect the answer is simply to delete that. The original comment about math being small was most likely because \sum was set in inline style which you already fixed using align. 14pt math in a 10pt running text will make inline math unusable even if it is just about OK in display math. Commented Jul 19, 2023 at 16:36
  • @DavidCarlisle ah right, I understand, I didn't know that about sum! Thanks for the feedback, I have removed reference to \DeclareMathSizes and will await feedback from the OP if they need further change
    – JamesT
    Commented Jul 19, 2023 at 16:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .