Martim Correia
Martim Correia

Reputation: 505

Resizing and allining text in latex

So I have a matrix like that in the code and a formula, the problem is that I want to limit the font size to 11 pt with cambria math font style and the matrices I want to limit to 10 pt. Also I want to align all those formulas to the left because for some reason they're all centered but if I put \: or put \small it doesn't do anything.

Code:

\documentclass[13pt,leqno]{article}
\pagestyle{headings}
\usepackage{amsmath}
%\usepackage[left=2.2cm, top=2cm, right=1.32cm, bottom=1.59cm]{geometry}
\usepackage{titlesec}
\usepackage{xcolor}
\titleformat{\section}[block]{\Large\bfseries\filcenter}{}{1em}{}
\setcounter{secnumdepth}{0}
\begin{document}
\date{\vspace{-10ex}}
\:\:\:\:\:\:1º) Fazemos uma forward propagation:
$$ T^{^{\left[1\right]}}=W^{^{\left[1\right]}}\cdot X^{^{\left[0\right]}}+b^{^{\:\left[1\right]}}=\begin{bmatrix}6\\ 1\\ 6\end{bmatrix} \:\:\:\:\:\:\:\:\:\: X^{^{\left[1\right]}}=tanh\left(\begin{bmatrix}6\\ 1\\ 6\end{bmatrix}\right)=\begin{bmatrix}0.9999877\\ 0.761594\\ 0.9999877\end{bmatrix}$$ \\

$$ T^{^{\left[2\right]}}=W^{^{\left[2\right]}}\cdot \:\:\:X^{^{\left[1\right]}}+b^{^{\:\left[2\right]}}=\begin{bmatrix}3.7615694\\ \:3.7615694\end{bmatrix}  \:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\: X^{^{\left[2\right]}}=tanh\left(\begin{bmatrix}3.7615694\\ \:\:3.7615694\end{bmatrix}\right)=\begin{bmatrix}0.99891972\\ \:0.99891972\end{bmatrix}$$

$$ {\small T^{^{\left[3\right]}}=W^{^{\left[3\right]}}\cdot \:\:X^{^{\left[2\right]}}+b^{^{\:\left[3\right]}}=\begin{bmatrix}0\\ 0\end{bmatrix} \:\:\:\:\:\:\:\:\:\: X^{^{\left[3\right]}}=tanh\left(\begin{bmatrix}0 \\ 0\end{bmatrix}\right)=\begin{bmatrix}0 \\ 0\end{bmatrix}}$$
\end{document}

Example image:

example

As you can see in that image the formulas are in the center instead of being on the left and for some reason they're too big and I want them small with 10pt instead of that size

Upvotes: 2

Views: 1082

Answers (1)

  • the 13pt documentclass option does not exist. A warning message will tell you that 10pt will be used instead. However if you use 11pt your normal math size will already be what you want.

  • instead of manually messing with all these \:, use an flalign environment. This will nicely align all your equal sign etc.

  • to change the math font to something from your system, you can compile with xelatex or lualatex and use the unicode-math package to set the font. I don't have cambria installed, so I'm using texgyrepagella-math.otf for this example.

  • to make the numbers within the matrices smaller, you could use the \mathsmaller macro from the relsize package. This will automatically choose the a smaller fonts size with is harmony with the original size. Then distance between 10pt and 11pt is really too small to be pleasant to read. (I only did the last matrix, too lazy to change them all)

  • you should use \tanh to get the correct upright font for it


% !TeX TS-program = lualatex
\documentclass[
11pt,
leqno]{article}


\pagestyle{headings}
\usepackage[leqno]{amsmath}
%\usepackage[left=2.2cm, top=2cm, right=1.32cm, bottom=1.59cm]{geometry}
\usepackage{titlesec}
\usepackage{xcolor}
\titleformat{\section}[block]{\Large\bfseries\filcenter}{}{1em}{}
\setcounter{secnumdepth}{0}

\usepackage{fontspec}
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}
\usepackage{relsize}

\begin{document}
%\date{\vspace{-10ex}}
1º) Fazemos uma forward propagation:
\begin{flalign*}
T^{^{\left[1\right]}}&=W^{^{\left[1\right]}}\cdot X^{^{\left[0\right]}}+b^{^{\left[1\right]}}=\begin{bmatrix}6\\ 1\\ 6\end{bmatrix} & X^{^{\left[1\right]}}&=\tanh\left(\begin{bmatrix}6\\ 1\\ 6\end{bmatrix}\right)=\begin{bmatrix}0.9999877\\ 0.761594\\ 0.9999877\end{bmatrix}\\
T^{^{\left[2\right]}}&=W^{^{\left[2\right]}}\cdot X^{^{\left[1\right]}}+b^{^{\left[2\right]}}=\begin{bmatrix}3.7615694\\ 3.7615694\end{bmatrix}  & X^{^{\left[2\right]}}&=\tanh\left(\begin{bmatrix}3.7615694\\ 3.7615694\end{bmatrix}\right)=\begin{bmatrix}0.99891972\\ 0.99891972\end{bmatrix}\\
T^{^{\left[3\right]}}&=W^{^{\left[3\right]}}\cdot X^{^{\left[2\right]}}+b^{^{\left[3\right]}}=\begin{bmatrix}0\\ 0\end{bmatrix} &  X^{^{\left[3\right]}}&=\tanh\left(\begin{bmatrix}0 \\ 0\end{bmatrix}\right)=\begin{bmatrix}\mathsmaller{0} \\ \mathsmaller{0}\end{bmatrix}\\
\end{flalign*}
\end{document}

enter image description here

Upvotes: 1

Related Questions