Text Formattingvert alignment of math in minipage

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
jaybz
Posts: 90
Joined: Sun Jul 11, 2010 6:02 pm

vert alignment of math in minipage

Post by jaybz »

How can I add horizontal space between these minipages and still have the boxes aligned at the top? hspace seams to have no effect.I also need captions at the top of each box which are aligned horizontally to their respective box. I will also be adding two or three more sets of boxes to the page later.

Code: Select all

\documentclass[a4paper,25pt]{article}
\usepackage[top=.5in, bottom=1in, left=0.5in, right=0.5in]{geometry} 
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\begin{document}

\begin{center}
\begin{minipage}[t]{.25\linewidth}
\vspace{0pt}
\centering
\fbox{$\displaystyle
  \begin{alignedat}{2}
    sin(\,x+y\,) &= sin(x)cos(x)\,+\,cos(x)sin(y) \\
    sin(\,x-y\,) &= sin(x)cos(x)\,+\,cos(x)sin(y) \\
    cos(\,x+y\,) &= cos(x)cos(y)\,-\,sin(x)sin(y) \\
    cos(\,x-y\,) &= cos(x)cos(y)\,+\,sin(x)sin(y) \\
    tan(\,x+y\,) &= \frac{tan(x)+tan(y)}{1-tan(x)\,tan(y)} \\
    tan(\,x+y\,) &= \frac{tan(x)-tan(y)}{1+tan(x)\,tan(y)} \\
  \end{alignedat}
$}
\hspace*{40pt}
\end{minipage}%
\begin{minipage}[t]{.25\linewidth}
\vspace{0pt}
\centering
\fbox{$\displaystyle
  \begin{alignedat}{2}
    sin^{2}(x) &= \frac{1-cos(2x)}{2} \\
    cos^{2}(x) &= \frac{1+cos(2x)}{2}  \\
    tan^{2}(x) &= \frac{1-cos(2x)}{1+cos(2x)}  \\
  \end{alignedat}
$}
\end{minipage}
\end{center}

\end{document}
Last edited by jaybz on Sun Dec 19, 2010 8:35 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

vert alignment of math in minipage

Post by gmedina »

Hi,

place the \hspace* command outside the minipage environment. You'll also have to increase the width of the first minipage to prevent an overfull box.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

vert alignment of math in minipage

Post by CrazyHorse »

jaybz wrote:How can I add horizontal space between these minipages and still have the boxes aligned at the top? hspace seams to have no effect.I also need captions at the top of each box which are aligned horizontally to their respective box. I will also be adding two or three more sets of boxes to the page later.

Code: Select all

\documentclass[a4paper,12pt]{article}
\usepackage[top=.5in, bottom=1in, left=0.5in, right=0.5in]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{varwidth}
\begin{document}

\begin{center}
\begin{varwidth}[t]{\linewidth}
\vspace{0pt}
\fbox{$\displaystyle
  \begin{alignedat}{2}
    sin(\,x+y\,) &= sin(x)cos(x)\,+\,cos(x)sin(y) \\
    sin(\,x-y\,) &= sin(x)cos(x)\,+\,cos(x)sin(y) \\
    cos(\,x+y\,) &= cos(x)cos(y)\,-\,sin(x)sin(y) \\
    cos(\,x-y\,) &= cos(x)cos(y)\,+\,sin(x)sin(y) \\
    tan(\,x+y\,) &= \frac{tan(x)+tan(y)}{1-tan(x)\,tan(y)} \\
    tan(\,x+y\,) &= \frac{tan(x)-tan(y)}{1+tan(x)\,tan(y)} \\
  \end{alignedat}
$}
\hfill
\end{varwidth}%
\begin{varwidth}[t]{\linewidth}
\vspace{0pt}
\fbox{$\displaystyle
  \begin{alignedat}{2}
    sin^{2}(x) &= \frac{1-cos(2x)}{2} \\
    cos^{2}(x) &= \frac{1+cos(2x)}{2}  \\
    tan^{2}(x) &= \frac{1-cos(2x)}{1+cos(2x)}  \\
  \end{alignedat}
$}
\end{varwidth}
\end{center}

\end{document}
Herbert
jaybz
Posts: 90
Joined: Sun Jul 11, 2010 6:02 pm

Re: vert alignment of math in minipage

Post by jaybz »

Thank you that's almost got it but how do I put a caption above each box?
Post Reply