TeX - LaTeX Asked on June 12, 2021
I could achieve the following using figure
and table
:
And using some multiline alignment I can align the "captions" (which is actually text) to the center:
However I’d like to be able to refer to each row using ref
, therefore I need each row to be a subfigure, with the caption on the left, without the word "Figure".
How can it be achieved?
This is the code I used so far, using a table:
begin{figure}[ht]
centering
par%
begin{tabular}{ccc}
& RGB & NIR
(a) & includegraphics[width=.3linewidth]{whatever.jpg} & includegraphics[width=.3linewidth]{whatever.jpg}
(b) & includegraphics[width=.3linewidth]{whatever.jpg} & includegraphics[width=.3linewidth]{whatever.jpg}
(c) & includegraphics[width=.3linewidth]{whatever.jpg} & includegraphics[width=.3linewidth]{whatever.jpg}
(d) & includegraphics[width=.3linewidth]{whatever.jpg} & includegraphics[width=.3linewidth]{whatever.jpg}
end{tabular}
caption{some caption}.}%
label{fig:fig1}%
end{figure}
I also managed to do a figure of subfigures, but the captions appeared in the bottom.
The following sample code should get you started.
documentclass{article}
usepackage{array,booktabs}
newcolumntype{M}[1]{>{centeringarraybackslash}m{#1}} % w/ horizontal centering
usepackage{subcaption} % for 'subfigure' environment
usepackage[demo]{graphicx}
begin{document}
begin{figure}[ht!]
setlengthtabcolsep{3pt} % default: 6pt
centering
begin{tabular}{@{} r M{0.3linewidth} M{0.3linewidth} @{}}
& RGB & NIR
begin{subfigure}{0.05linewidth} caption{}label{subfig:a} end{subfigure}
& includegraphics[width=hsize]{whatever.jpg}
& includegraphics[width=hsize]{whatever.jpg} addlinespace
begin{subfigure}{0.05linewidth} caption{}label{subfig:b} end{subfigure}
& includegraphics[width=hsize]{whatever.jpg}
& includegraphics[width=hsize]{whatever.jpg} addlinespace
begin{subfigure}{0.05linewidth} caption{}label{subfig:c} end{subfigure}
& includegraphics[width=hsize]{whatever.jpg}
& includegraphics[width=hsize]{whatever.jpg} addlinespace
begin{subfigure}{0.05linewidth} caption{}label{subfig:d} end{subfigure}
& includegraphics[width=hsize]{whatever.jpg}
& includegraphics[width=hsize]{whatever.jpg}
end{tabular}
caption{Four rows of graphs}
label{fig:fig1}
end{figure}
noindent
Cross-references to subfigures ref{subfig:a} and ref{subfig:d}.
end{document}
Correct answer by Mico on June 12, 2021
The original idea was to use subcaption
in the first column, but its baseline is at the top making vertical alignment difficult. And yes, you can use label
with tabcaption
.
documentclass{article}
usepackage{graphicx}
usepackage{subcaption}% or newcounter{subfigure}[figure]
usepackage{duckuments}% just for fun
usepackage{array}
newcolumntype{v}{>{sbox0bgroup}c<{egroupraisebox{dimexpr 0.5dp0-0.5ht0}%
[dimexpr 0.5ht0-0.5dp0+1pt][dimexpr 0.5ht0-0.5dp0+1pt]{usebox0}}}
newcommand{tabcaption}{refstepcounter{subfigure}(thesubfigure)}
begin{document}
begin{figure}[ht]
centering
begin{tabular}{vvv}
& RGB & NIR
tabcaption & includegraphics[width=.3linewidth]{example-image-duck}
& includegraphics[width=.3linewidth]{example-image-duck}
tabcaption & includegraphics[width=.3linewidth]{example-image-duck}
& includegraphics[width=.3linewidth]{example-image-duck}
tabcaption & includegraphics[width=.3linewidth]{example-image-duck}
& includegraphics[width=.3linewidth]{example-image-duck}
tabcaption & includegraphics[width=.3linewidth]{example-image-duck}
& includegraphics[width=.3linewidth]{example-image-duck}
end{tabular}
caption{some caption}% note: caption begins and ends with a par
label{fig:fig1}
end{figure}
end{document}
Answered by John Kormylo on June 12, 2021
With use of the floatrow
and subfig
packages:
documentclass{article}
usepackage{graphicx}
usepackage{floatrow}
usepackage[label font=bf, labelformat=simple]{subfig}
floatsetup[figure]{style=plain,subcapbesideposition=center}
begin{document}
%---------------------------------------------------------------%
begin{figure}
centering
setkeys{Gin}{width=0.45textwidth}
quadparbox{0.45linewidth}{hfil RGB} parbox{0.45linewidth}{hfil NIR}
smallskip
sidesubfloat[label{fig:a}]%
{includegraphics{example-image-duck}
hfil
includegraphics{example-image-duck}
}
medskip
sidesubfloat[label{fig:b}]%
{includegraphics{example-image-duck}
hfil
includegraphics{example-image-duck}
}
medskip
sidesubfloat[label{fig:b}]%
{includegraphics{example-image-duck}
hfil
includegraphics{example-image-duck}
}
caption{main caption}
label{fig:myfigure}
end{figure}
end{document}
Answered by Zarko on June 12, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP