TransWikia.com

Why minipage subfigures caption number is treated as a separate figure?

TeX - LaTeX Asked by Hassen Nigatu on June 27, 2021

I usually use subfigure. But this time I am forced to use minipage.However, subfigures captions are appear to be Figure 1, Figure 2…..
However, I want figure 1a, 1b….
Can anyone suggest a solution ? I also tried subfloat but the error message I am getting is Missing endcsname inserted. subfloat

Thanks

    begin{minipage}{.49columnwidth}
        caption{Subfigure (alph{figure})}
        includegraphics[width=textwidth]{example-image-a}
        label{fig:subfig1}
    end{minipage}
    begin{minipage}{.49columnwidth}
        caption{Subfigure (alph{figure})}
        includegraphics[width=textwidth]{example-image-b}
        label{fig:subfig2}
    end{minipage}
    begin{minipage}{.49columnwidth}
        caption{Subfigure (alph{figure})}
        includegraphics[width=textwidth]{example-image-c}
        label{fig:subfig3}
    end{minipage}
    begin{minipage}{.49columnwidth}
        caption{Subfigure (alph{figure})}
        includegraphics[width=textwidth]{example-image}
        label{fig:subfig4}
    end{minipage}

One Answer

enter image description here

documentclass{article}
usepackage{subcaption}
usepackage{pgffor}
usepackage{alphalph}

renewcommandthesubfigure{1alphalph{value{subfigure}}}

begin{document}
    begin{figure}
        foreach i in {1,...,20}{
            begin{minipage}[b]{.3linewidth}
                centeringlarge Ai
                subcaption{A subfigure}label{fig:1Ai}
            end{minipage}%
            begin{minipage}[b]{.3linewidth}
                centeringlarge Bi
                subcaption{A subfigure}label{fig:1bi}
            end{minipage}
            begin{minipage}[b]{.3linewidth}
                centeringlarge Ci
                subcaption{A subfigure}label{fig:1ci}
            end{minipage}
        }
    end{figure}
end{document} 

OR

documentclass{article}
usepackage{subcaption}
usepackage{pgffor}
usepackage{alphalph}
usepackage[demo]{graphicx}

renewcommandthesubfigure{1alphalph{value{subfigure}}}

begin{document}
    begin{figure}
            begin{minipage}[b]{.3linewidth}
                centering        includegraphics[width=textwidth]{example-image-a}
                subcaption{A subfigure}
            end{minipage}%
    end{figure}
end{document} 

enter image description here

Answered by js bibra on June 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP