Page LayoutAlignment in Minipages

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
ghuczek
Posts: 23
Joined: Sun Dec 23, 2012 8:09 pm

Alignment in Minipages

Post by ghuczek »

I want the two circuit diagrams to align on the battery V_T, horizontally using minipage. I have the two circuits drawn as I want them using circuitikz. What do I need to do to correct the alignment?

Code: Select all

\documentclass[12pt,letterpaper,onecolumn]{article}
%\usepackage[utf8]{inputenc}
\usepackage{amsmath}
%\usepackage{amsfonts}
%\usepackage{amssymb}
%\usepackage{graphicx}
\usepackage{tikz}	
\usepackage{circuitikz}

%\usepackage{lmodern}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}

\begin{document}
%\hspace{.1cm}
\vspace{4 cm}
\begin{minipage}[t]{.8 in}
%parallel circuit
	\begin{circuitikz}[scale=1.5]\draw
		(0,2) to [battery, l_= $V_T$, i<^ =$I_1$] (0,0)
		(0,0) -- (6,0)
		(6,2) -- (0,2)
		(4,2) to [R, l=$R$] (4,0)
		(6,2) to [R, l=$R$] (6,0)
		(2,2) to [R, l=$R$] (2,0);
	\end{circuitikz}
\end{minipage}
\hfill
\begin{minipage}[t]{2.5 in}
%series circuit
\hspace{15 pt}
%\vspace{.6 cm}
%\hfill
	\begin{circuitikz}[scale=1.5] \draw
		(0,2) to [battery, l_= $V_{\text{T}}$,i<^=$I_2$] (0,0)
		(0,2) to [R,l=$R$] (2,2)
		(2,2) to [R,l=$R$] (2,0)
		(2,0) to [R,l=$R$] (0,0);
	\end{circuitikz}
\end{minipage}\medskip

\end{document}

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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Alignment in Minipages

Post by Johannes_B »

Hi, you could use a bounding box to give the two different picture the same "starting point". Please consult the manual for more information.

Code: Select all

\documentclass[12pt,letterpaper,onecolumn]{article}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{circuitikz}

\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}

\begin{document}
\begin{minipage}[t]{0.55\linewidth}
%parallel circuit
        \begin{circuitikz}[scale=1.4]
        \useasboundingbox (-1,-1.1) rectangle (6.1,3);
        \draw
                (0,2) to [battery, l_= $V_T$, i<^ =$I_1$] (0,0)
                (0,0) -- (6,0)
                (6,2) -- (0,2)
                (4,2) to [R, l=$R$] (4,0)
                (6,2) to [R, l=$R$] (6,0)
                (2,2) to [R, l=$R$] (2,0);
        \end{circuitikz}
\end{minipage}
\hfill
\begin{minipage}[t]{0.35\linewidth}
%series circuit
        \begin{circuitikz}[scale=1.4] 
        \useasboundingbox (-1,-1.1) rectangle (2,3);
        \draw
                (0,2) to [battery, l_= $V_{\text{T}}$,i<^=$I_2$] (0,0)
                (0,2) to [R,l=$R$] (2,2)
                (2,2) to [R,l=$R$] (2,0)
                (2,0) to [R,l=$R$] (0,0);
        \end{circuitikz}
\end{minipage}\medskip

\end{document}
I also changed the width of the minipages, and deleted all thos vskips. I think you are more flexible, if those width are a fraction of your linewidth.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
ghuczek
Posts: 23
Joined: Sun Dec 23, 2012 8:09 pm

Alignment in Minipages

Post by ghuczek »

Thank you. That works very well. I'll study the differences in the code, especially the use of the \useasboundingbox idea to give the same starting point.
Post Reply