I was looking for ways to have a side-by-side minipages on a Latex beamer.
I will be clear, this is not two columns or mult-column or whatever. I specifically need minipages.
To do so, I created a nice command/function which does it nicely, but I am trying to make the two miniapges always be equal in height as well.
Any suggestions on how to force them to be equal in size?
Also general improvement suggestions and tips are welcomed.
\def \MinSideBySideGap {0.02} % minimal Gap between left/right sides
\newcommand{\SideBySide}[3][0.5]
{
%
\ifthenelse{\isempty{#1}}%
{\FPeval{\leftwidth}{0.5-\MinSideBySideGap/2}%
\FPeval{\rightwidth}{\leftwidth}%
}% if #1 is empty
{\FPeval{\leftwidth}{min(#1-\MinSideBySideGap/2,1.0)}%
\FPeval{\rightwidth}{max(1.0-\leftwidth-\MinSideBySideGap,0.0)}
}% if #1 is not empty
%
% Left Part
\begin{minipage}{\leftwidth\textwidth}
#2
\end{minipage}%
\hfill%
% Right Part
\begin{minipage}{\rightwidth\textwidth}
#3
\end{minipage}%
}
Towards #samcarter_is_at_topanswers.xyz questions, this was the very old origin of this:
\newcommand{\SideBySide}[2]
{
\begin{columns}[T] % align columns
\begin{column}{.48\textwidth}
#1
\end{column}%
\hfill%
\begin{column}{.48\textwidth}
#2
\end{column}%
\end{columns}
}
I still don't see a reason why you would need minipages of the same height, but just as a proof of concept, you could use tcoloboxes instead of minipages. They have the ability to form "equal height groups":
\documentclass{beamer}
\usepackage[most]{tcolorbox}
\tcbset{width=(\linewidth-4mm)/2,before=,after={},enhanced,interior empty,equal height group=\insertframenumber,frame hidden}
\begin{document}
\begin{frame}
\begin{tcolorbox}%
test
\end{tcolorbox}%
\hfill%
\begin{tcolorbox}%
test
test
\end{tcolorbox}%
\end{frame}
\end{document}
(for the image, I removed the interior empty option so one can see the height of the box)
Related
My code is as following but my figures are not centre aligned with captions. How can I fix it?
code result
\begin{figure}[H]
\centering
\begin{subfigure}{0.7\textwidth}
\includegraphics[width=4cm,height=6cm]{outwithsel.PNG}
\caption{Outliner}
\label{fig:h1}
\end{subfigure}
\begin{subfigure}{\textwidth}
\includegraphics[width=0.8\linewidth]{moveBtns.PNG}
\caption{Buttons that move selected object in 4 different directions}
\label{fig:h2}
\end{subfigure}
\caption{Kitchen is selected and can be moved to where desired}
Here somaia, that's what happens when I tried what you said. fix from comment 1
Your images have the widths 4cm and .8\textwidth, respectively. This means they are smaller than the subfigure around them. To get them centred inside the bigger subfigure, you need to repeat \centering inside the subfigure.
In addition there are missing % at the end of some of your lines. These unprotected line breaks will act like a space, and thus decentre your subfigure by a small amount (probably not noticeable, but when we are already at it...).
Unrelated to your problem: don't specify both the width and the height of the image, this will distort it. At least add keepaspectratio if you really must give both dimensions.
\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{float}
\begin{document}
\begin{figure}[H]
\centering
\begin{subfigure}{\textwidth}
\centering
\includegraphics[width=4cm,height=6cm]{example-image-duck}
\caption{Outliner}
\label{fig:h1}
\end{subfigure}%
\begin{subfigure}{\textwidth}
\centering
\includegraphics[width=.8\textwidth]{example-image-duck}
\caption{Buttons that move selected object in 4 different directions}
\label{fig:h2}
\end{subfigure}%
\caption{Kitchen is selected and can be moved to where desired}
\end{figure}
\end{document}
I think you have a problem in \texwidth, you have to choose the 0.5 textwidth for each subfigure
This will solve your problem:
\begin{figure}[H]
\centering
\includegraphics[width=.7\textwidth]{Bloch sphere.PNG}
\caption{Outliner}
\label{fig:h1}
\includegraphics[width=0.7\textwidth]{Bloch sphere.PNG}
\caption{Buttons that move selected object in 4 different directions}
\label{fig:h2}
\caption{Kitchen is selected and can be moved to where desired}
\end{figure}
I'm seeking to layout paragraphs as follows:
1. In the introduction, I'd have the paragraphs across all columns.
2. Then follow two columns with opposing opinions in parallel. It differs than a two-columns layout that the two columns will be parallel and that the content on the left will always remain on the left, the right always on the right across multiple pages. Even if the amount of argument of the left column is shorter, the argument of the right column should not float into the left column.
Here is an example in HTML:
https://www.biblegateway.com/passage/?search=1+Corinthians+15&version=CCB;KJ21
Used to compare different translations.
Below is my attempt to achieve the effect.
\documentclass{report}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\section{Introduction}
Here are the normal paragraph crossing colmuns.
\blindtext
\begin{minipage}[t]{0.5\textwidth}
\section{Argument on the Left}
Because I am on the left, so must I be not right?
\end{minipage}\begin{minipage}[t]{0.5\textwidth}
\section{Argument on the Right}
Because I am on the right, so I must be right!
\blindtext
\end{minipage}
\end{document}
It almost achieved the effect, except that there is no gap between the two columns.
Here is a screenshot of the result:
What would be a better solution?
How could I achieve the same in org-mode with export to PDF (via LaTex)?
To have separated columns, it is sufficient to use smaller minipages and to add a space between them. Minipages are boxes, and you can either use a fixed space (with ~~~ or \hspace{}), but the better is rubber space \hfill.
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\section{Introduction}
Here are the normal paragraph crossing colmuns.
\blindtext
\noindent\begin{minipage}[t]{0.48\textwidth}
\section{Argument on the Left}
Because I am on the left, so must I be not right?
\end{minipage}%
\hfill%
\begin{minipage}[t]{0.48\textwidth}
\section{Argument on the Right}
Because I am on the right, so I must be right!
\blindtext
\end{minipage}
\end{document}
\noindent avoids the normal paragraph spacing and \hfill "pushes minipage towrads left and right margin.
But it is not the best solution. You will have problems to manage properly page breaks and there is a specific package to does exactly what you want.
The package paracol defines a parallel environment with 2 (or more) columns and provides a way to "synchronize" them by switching between cols. It takes care of page breaks and is definitely what you want.
Here is an example with paracol
\documentclass{report}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{paracol}
\begin{document}
\section{Introduction}
Here are the normal paragraph crossing colmuns.
\blindtext
\begin{paracol}{2}
\section{Argument on the\\ Left}
Because I am on the left, so must I be not right?
\switchcolumn
\section{Argument on the\\ Right}
Because I am on the right, so I must be right!
\blindtext
\end{paracol}
\end{document}
As you can see, section numbering is coherent between columns, but there are many ways to customize the package if you prefer not. Look at the documentation
Also note that I had to add a manual line break to have section titles properly formatted, but it is a minor drawback.
Concerning, org-mode, I use it, but I have no experience with export and cannot really help you. But with the flexibility of paracol, you can find some way to define macros that do what you need. Maybe if you provide a org-mode export, people can try to find a solution.
I'm trying to make alignment points in a list environment. The following code gives me an error, but it almost compiles to what I want, just missing the bullet points. I must be misunderstanding something about align and/or tabular and how they work with linebreaks. Guidance appreciated!
\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{Title}
\begin{itemize}
\begin{tabular}{ll}
\item Topic Apple: &Something to say about it \\
\item Topic Watermelons: &Something different
\end{tabular}
\end{itemize}
\end{frame}
\end{document}
How about this?
\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{Title}
\begin{tabular}{p{0.4\textwidth}p{0.5\textwidth}}
\begin{itemize}
\item Topic Apple:
\item Topic Watermelon:
\end{itemize} &
\begin{itemize}
\item[] Something to say about it
\item[] Something to say about it
\end{itemize} \\
\end{tabular}
\end{frame}
\end{document}
Yours will actually work if you change {ll} to {p{width}l} or {p{width}p{width}} but I found that if you don't have itemize in the second column, your text ends up vertically top aligned while the itemized text in the left column is center (or maybe even slightly bottom) aligned vertically so it doesn't look good.
I tried using the array package and m{width} which provides a vertical center alignment but that was still different than whatever itemize is using. I'd say just play with the width argument inside of p{} to get the spacing/width you want. If your right column spills on to another line, you may need a "dummy" item in the right column.
Anyway, based on all the jimmy rigging that might be necessary if things spill onto two lines, I'm assuming my solution is potentially hackish but it looks like it provides what you want for the most part.
the \item[] for the right column is to create the same itemize alignment with no bullet. If you want bullets on the right, just remove the empty square brackets and you'll have them.
How do I center text within a listing in Latex?
Or another way not using listing. (Need a box with monospace font)
The answer given at tex.stackexchange is:
\documentclass{article}
\usepackage{listings}
\renewcommand{\figurename}{Listing}
% replace figurename with the text that should preceed the caption
\begin{document}
\begin{figure}[thp] % the figure provides the caption
\centering % which should be centered
\caption{Ausgabe des C-Programms}
\begin{tabular}{c} % the tabular makes the listing as small as possible and centers it
\begin{lstlisting}[label={gtt_c_ausgabe}]
printf("Your code goes here.\n");
\end{lstlisting}
\end{tabular}
\end{figure}
\end{document}
...which still leaves me wondering:
Using a frame around the code, e.g. using \lstset{frame=single,frameround=tttt}, places the frame way over to the right. How can this be avoided?
What does the renewcommand bit do?
I don't have an answer for the listing package on top of my head, but you could try the following:
\framebox[.9\linewidth]{\parbox{.85\linewidth}{\tt Hello World\\Second line}}
That produces a box with 90% of the line width, with text of width 85% of line width.
If you want it centered you just put \centering in front of the \tt command:
\framebox[.9\linewidth]{\parbox{.85\linewidth}{\centering \tt Hello World\\Second line}}
If you prefer the box without a frame, simply change \framebox into \makebox (and keep the arguments as they stand).
For some reason I thought it would be nice to have inline figures (i.e. no floats) just like the equation environment. They would have to be numbered, as I want to be able to refer to them later on. I've come up with two attempts, but both have their shortcomings. I'm hoping for some feedback that can sort me out.
The first attempt uses 3 minipages (see the code below). This looks nice as the figure number is aligned vertically with the middle of the figure. However, as the width of the figure approaches the width of the page, things start to break down. Also, it doesn't behave very nicely at pagebreaks.
The second attempt uses the equation environment with a different label. Apart from the fact that I don't know if this is a sensible thing to do, it produces extra whitespace in the beginning of the next paragraph. It also doesn't align the label vertically in the center, but puts it on the bottom.
Here's an example of both attempts:
\documentclass{article}
\usepackage{pgf,tikz}
\usepackage{lipsum}
%
% Attempt 1
%
% Uses 3 minipages.
% Breaks if figure is wide, and at the bottom of a page.
%
\usepackage{calc}
\newlength{\figlabelwidth} % width of label
\newlength{\imgwidth} % max. width of figure
\newenvironment{inlinefig1}
{
\refstepcounter{figure} % increase figure number
\begin{center} % don't know if this is necessary
\setlength{\figlabelwidth}{\widthof{(Fig. \thefigure)}}
\setlength{\imgwidth}{\textwidth - \figlabelwidth - \figlabelwidth}
\setlength{\imgwidth}{0.9\imgwidth} % to be on the safe side
\begin{minipage}{\figlabelwidth}\makebox[\figlabelwidth]{}\end{minipage} % ghost minipage for centering
\hfill
\begin{minipage}{\imgwidth}\begin{center} % minipage for figure
}
{
\end{center}\end{minipage}
\hfill
\begin{minipage}{\figlabelwidth}(Fig. \thefigure)\end{minipage} % minipage for label
\end{center}
}
%
% Attempt 2
%
% Uses an equation environment with relabeled labels.
% Label is not centered vertically, and produces extra whitespace in the paragraph after it.
%
\def\theoldequation{\theequation} % save the old equation format
\newenvironment{inlinefig2}
{
\refstepcounter{figure} % increase figure number
\def\theequation{Fig. \arabic{figure}} % switch to figure numbering
\begin{equation}
}
{
\end{equation}
\def\theequation{\theoldequation} % reset to old equation label format
\addtocounter{equation}{-1} % correct the equation numbering
}
\begin{document}
\noindent \lipsum[1]
\begin{inlinefig1}
\begin{tikzpicture}
\draw (0,0) grid +(12,2);
\end{tikzpicture}
\end{inlinefig1}
\lipsum[2]
\begin{inlinefig2}
\begin{tikzpicture}
\draw (0,0) grid +(12,2);
\end{tikzpicture}
\end{inlinefig2}
\lipsum[3]
\end{document}
Do you guys have any better ideas, or suggestions to fix the any of the shortcomings? Thanks!
If you use the "float" package, you can specify H as a placement, which makes it appear exactly "here".
\newbox\inlinefigbox
\newenvironment{inlinefig3}
{
\refstepcounter{figure} % increase figure number
\setbox\inlinefigbox=\hbox\bgroup
}
{
\egroup
\hbox to \hsize{\hfil \box \inlinefigbox \hss (Fig. \arabic{figure})}
}