Latex: how to align subcaptions on the top left and caption to the right of the figures - latex

I am using LaTeX to write a report and I'm going crazy to get a result like
with subcaptions (a), (b), (c) align to the top left of the subfigures and caption on the right of the figure.
I've already tried with floatrow and subcaption, but I've never obtained the result I want.
MWE:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{floatrow}
\usepackage{subfig}
\floatsetup[figure]{style=plain,subcapbesideposition=top}
\begin{figure*}
\ffigbox[\FBwidth]
{\begin{subfloatrow}
\sidesubfloat[]{\includegraphics[width=.5\linewidth]{image1}\label{fig:a}}%
\sidesubfloat[]{\includegraphics[width=.5\linewidth]{image2}\label{fig:b}}%
\end{subfloatrow}}
{\caption{Two figures}\label{}}
\end{figure*}
\end{document}

Here some starting point with the subcaption package (the exact dimensions might need some tweaking to nicely align with the surrounding text)
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\captionsetup[subfigure]{font={bf,small}, skip=1pt, margin=-0.7cm, singlelinecheck=false}
\begin{document}
\begin{figure*}
\hfill
\begin{minipage}[b]{.63\textwidth}
\begin{subfigure}{\textwidth}
\subcaption{}
\includegraphics[width=\linewidth]{example-image-duck}
\end{subfigure}\par
\begin{subfigure}{\textwidth}
\subcaption{}
\includegraphics[width=\linewidth]{example-image-duck}
\end{subfigure}
\end{minipage}
\quad
\begin{minipage}[b]{.3\textwidth}
\caption{some caption with aligns at the bottom}\label{key}
\end{minipage}
\end{figure*}
\end{document}

Related

LaTex - Extra space between words of footnotes in figure environment

there is extra space between the words of the footnotes in the figure below. How can I fix this issue?
\documentclass[jou]{apa7}
\begin{document}
\begin{figure*}
\centering
\caption{Title}
\vspace{0.3cm}
\includegraphics[width=\textwidth]{example.png}
\vspace{4pt}
\begin{tablenotes}[para,flushleft]
{\small \textit{Note.} Figure notes here }
\end{tablenotes}
\end{figure*}
\end{document}
Your table note tries to fill the whole line. To avoid the extra space you can add \hfill at the end to fill the line.
\documentclass[jou]{apa7}
\shorttitle{subtitle}
\begin{document}
\begin{figure*}
\centering
\caption{Title}
\vspace{0.3cm}
\includegraphics[width=\textwidth]{example-image-duck}
\vspace{4pt}
\begin{tablenotes}[para,flushleft]
{\small \textit{Note.} Figure notes here\hfill }
\end{tablenotes}
\end{figure*}
\end{document}

Latex: Left alignment for an equation

I have these two definitions:
\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{flalign*}
&\boldsymbol{R*^\sigma} & \sigma_{superset}(F)&=\sigma_{superset}(F')&\\
&\boldsymbol{R*_{weak}^\sigma} & \sigma_{superset}(F)&=\sigma_{superset}(F')\cap\mathcal{P}(A)&
\end{flalign*}
\end{document}
Compiled, it looks like this:
I want the equations to be aligned by "=" as they are; but also that they are not centered but quite next to the bold symbols. Like, also aligned left.
It should look like this (done with MS Paint):
If you don't mind that all equations will be left aligned, you could use the fleqn option of amsmath:
\documentclass[12pt]{article}
\usepackage[fleqn]{amsmath}
\setlength{\mathindent}{0pt}
\begin{document}
\noindent text
\begin{alignat*}{3}
&\boldsymbol{R*^\sigma} & \sigma_{superset}(F)&=\sigma_{superset}(F')\\
&\boldsymbol{R*_{weak}^\sigma} \quad& \sigma_{superset}(F)&=\sigma_{superset}(F')\cap\mathcal{P}(A)
\end{alignat*}
\end{document}
If you like to keep other equations centred, you could also switch temporarily:
\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
\[
a
\]
{
\makeatletter
\#fleqntrue
\makeatother
\begin{alignat*}{4}
&\boldsymbol{R*^\sigma} & \sigma_{superset}(F)&=\sigma_{superset}(F')\\
&\boldsymbol{R*_{weak}^\sigma} \quad& \sigma_{superset}(F)&=\sigma_{superset}(F')\cap\mathcal{P}(A)
\end{alignat*}
}
\[
a
\]
\end{document}

Figure in Latex is not centering despite using \centering

I am very new to LaTex and am trying to center a figure.
I have tried to use the package float using both [h] and [H], I have tried to add \centering and I have tried to wrap the image in \begin{center} \end{centering} but nothing seems to work.
My full code is as such
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{float}
\graphicspath{ {images/} }
\title{Dissertation}
\author{GC}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
\begin{figure}[H]
\centering
\includegraphics{my_grades}
\caption{grades plot}
\label{fig:grade}
\end{figure}
This figure does not seem to want to centre
\end{document}
This figure on the compiled document looks as such. If someone could help me understand why this doesn't want to move that would be great:
Your code seems fine, I just added a [width=50mm] in your include graphics and it centered the Figure.
I would check two issues:
Is your figure to larger than the textwidth?
Does your Figure has a white part on its lefthand side?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{float}
\graphicspath{ {images/} }
\title{Dissertation}
\author{GC}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
\begin{figure}[H]
\centering
\includegraphics[width=50mm]{darth-vader_5yvm.jpeg}
\caption{grades plot}
\label{fig:grade}
\end{figure}
This figure does not seem to want to centre
\end{document}

Ordering subfigures in LaTex

I have this code in LaTex:
\begin{figure}[h!]
\centering
\subfigure[]{\includegraphics[width=50mm]{katua.jpg}}
\subfigure[]{\includegraphics[width=60mm]{txakurren_balioak.png}}
\subfigure[]{\includegraphics[width=60mm]{katuen_balioak.png}}}
\label{fig:eb3}
\end{figure}
and I get this:
And I want to put the images in two columns. In the column of the left the image of the cat and in the right the two histograms. How it is possible to do this?
Instead of \centering you could use \hfill to do the centering, see the example below:
\documentclass{report}
\usepackage{graphicx}
\usepackage{subfigure}
\begin{document}
\begin{figure}[h!]
\hfill
\subfigure[]{\includegraphics[width=50mm]{example-image-a}}
\hfill
\subfigure[]{\includegraphics[width=60mm]{example-image-b}}
\hfill
\hfill
\subfigure[]{\includegraphics[width=60mm]{example-image-c}}
\end{figure}
\end{document}

LaTeX: Indent subcaption in figure environment

See this MWE:
% !TeX spellcheck = en_US
\documentclass[12pt]{article}
\usepackage[onehalfspacing]{setspace}
\usepackage[a4paper, margin=2.5cm]{geometry}
\usepackage{mathptmx}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[hang]{caption}
\usepackage{subcaption}
\usepackage[bottom]{footmisc}
\usepackage{dcolumn} %makes r output work
\usepackage{tabularx}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
\newcommand{\possessivecite}[1]{\citeauthor{#1}'s (\citeyear{#1})}
\usepackage{pdfpages}
\usepackage{hyperref}
\usepackage{pdflscape}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{landscape}
\setcapmargin[2cm]
\begin{figure}[]
\captionsetup{justification=centering}
\caption{Main Caption. }
\label{fig:val_efcts}
\begin{subfigure}{0.55\textwidth}
\caption{X}
\includegraphics[width=\textwidth] {example-image-a}
\end{subfigure}
\begin{subfigure}{0.55\textwidth}
\caption{Y}
\includegraphics[width=\textwidth] {example-image-b}
\end{subfigure}
\begin{subfigure}{0.55\textwidth}
\caption{Z}
\includegraphics[width=\textwidth] {example-image-c}
\end{subfigure}
\captionsetup{justification=raggedright} \subcaption*{This subcaption is supposed to be ragged right and intented by 4 cm. \\ This is in a new line.}
\end{figure}
\end{landscape}
\end{document}
It should be self-explanatory, mostly. I'd like the last subcaption below the picture to be ragged right, but indented 2 cm. I tried to use \setcapmargin, but that does not work, creating the "undefined control sequence" error (so it's an unknown command).
Since you're writing a caption without numbering, set it in a \parbox where you have some more control over the placement and alignment:
\documentclass{article}
\usepackage{graphicx}
\usepackage[hang]{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}[]
\captionsetup{justification=centering}
\caption{Main Caption. }
\label{fig:val_efcts}
\begin{subfigure}{0.3\textwidth}
\caption{X}
\includegraphics[width=\linewidth] {example-image-a}
\end{subfigure}\hfill
\begin{subfigure}{0.3\textwidth}
\caption{Y}
\includegraphics[width=\linewidth] {example-image-b}
\end{subfigure}\hfill
\begin{subfigure}{0.3\textwidth}
\caption{Z}
\includegraphics[width=\linewidth] {example-image-c}
\end{subfigure}
\hspace*{4cm}%
\parbox{\dimexpr\linewidth-8cm}{\raggedright
\strut This subcaption is supposed to be ragged right and indented by 4cm. \\
This is in a new line.\strut%
}
\end{figure}
\end{document}
Note the use of \struts to support correct baseline alignment when dealing with text inside \parboxes. For more on this, see How to keep a constant baseline skip when using minipages (or \parboxes)?

Resources