0

This is NOT a duplicate of Insert two images as subfigures vertically

I want two sub figures, vertically aligned. Question 229440 suggests using subfigure, but that requires \usepackage{subcaption}.

I cannot use subcaption since it "contradicts setting in LifeCon", where Life Con is a package which sets actuarial symbols. So, I suppose the question is "how can I solve the problem in Question 229440 while still being able to use actuarial notation with LifeCon"?

9
  • 1
    Welcome to TeX.SX! In case someone would like to test, where can one find LifeCon? Do you need separate captions for these? And in that case, do you want subcaptions, so you have e.g. figure 1a and 1b, or are they separate figures altogether, e.g. figure 1 and figure 2? Oct 28, 2016 at 15:28
  • Google for lifecon.sty, and go to Eddy Trivet's page: unalmed.edu.co/~ndgirald/Archivos%20Lectura/…
    – Mark T
    Oct 28, 2016 at 15:36
  • Yes, Sub captions are required (as are labels). If neither of these can be obtained, the I may as well just redraw the thing with all sub parts in single diagram -- but that seems a stupid use of LaTeX.
    – Mark T
    Oct 28, 2016 at 15:40
  • Just looked at the question you refer to. The accepted answer there doesn't use subcaption, but subfig. Also, where does it say that lifecon doesn't work with subcaption? At first glance it doesn't look like there is anything in lifecon.sty that would conflict with subcaption, and compiling a document with both packages works fine, no errors or warnings. Oct 28, 2016 at 15:53
  • 1
    Edit your question (there should be a link just between question and comments), comments are really not the place for blocks of code. Oct 28, 2016 at 16:09

2 Answers 2

0

You don't need lifecon for the following to work; I just set the content with manual "sub-figure captions":

enter image description here

\documentclass{article}

% https://github.com/spedygiorgio/lifecontingencies/blob/master/vignettes/lifecon.sty
\usepackage{lifecon}
\usepackage{lipsum,graphicx,etoolbox}

% Reset subcaption counters at the start of figure/table float
\AtBeginEnvironment{figure}{\setcounter{subcaption}{0}}%
\AtBeginEnvironment{table}{\setcounter{subcaption}{0}}%

\makeatletter
\newcounter{subcaption}% subcaption counter
\renewcommand{\thesubcaption}{(\alph{subcaption})}% subcaption counter representation
\newcommand{\subcaption}[1]{% \subcaption{<caption>}
  \refstepcounter{subcaption}% Step subcaption counter
  {\small\thesubcaption~#1}% Set subcaption
}
\makeatother

\begin{document}

\section{A section}
\lipsum[1]

See Figure~\ref{fig:figure}\ref{fig:sub-a} and~\ref{fig:sub-b}.

\begin{figure}[ht]
  \centering

  \includegraphics[width=15em]{example-image-a}

  \subcaption{A first sub-figure.}\label{fig:sub-a}

  \medskip

  \includegraphics[width=.4\linewidth]{example-image-b}

  \subcaption{A second sub-figure.}\label{fig:sub-b}

  \caption{A figure caption.}\label{fig:figure}
\end{figure}

\lipsum[2-10]

\end{document}

Here's a close-up of the reference:

enter image description here

5
  • I have updated your template to show what I need.
    – Mark T
    Oct 28, 2016 at 19:08
  • Edit now submitted. Actuarial symbols ARE required. The above does not solve my problem unless I can \ref and \label each sub figure. So, no this does not answer my question -- but it's close(ish).
    – Mark T
    Oct 28, 2016 at 19:22
  • until the edit becomes visible to all, I added $\lcEnd{A}{x}{n}$ after \begin{document}
    – Mark T
    Oct 28, 2016 at 19:25
  • @MarkT: I've added the capability to cross-reference a subcaption. Use \subcaption (in figure or table) and follow it by \label{<ref>} which you can then \ref{<ref>}.
    – Werner
    Oct 28, 2016 at 19:53
  • @MarkT: I've updated my answer to correct the way the subcaption counter was resetting.
    – Werner
    Oct 29, 2016 at 0:11
0

Using the float package, you can stuff figures inside minipages. However, the whole assembly will then no longer float.

\documentclass{article}
\usepackage{float}
\usepackage{mwe, boxedminipage,calc}
\usepackage[margin=0.5in,papersize={4in,4.5in}]{geometry}

\pagestyle{empty}

\begin{document}
\noindent  Text before \bigskip

\noindent 
\begin{boxedminipage}{\linewidth}
    \begin{boxedminipage}{\linewidth}
        \centering
        \begin{figure}[H] % the H must be here, or you will get 'not in outer par mode' error
            \includegraphics[width=0.8\linewidth]{/data/graphics/fun/asterix/switzerland-red-cross}
            \caption{This is the first figure}
        \end{figure}
    \end{boxedminipage}
    \medskip
    \begin{boxedminipage}{\linewidth}
        \centering
        \begin{figure}[H]
            \includegraphics[width=0.8\linewidth]{/data/graphics/fun/asterix/switzerland-red-cross}
            \caption{This is the second figure}
        \end{figure}
    \end{boxedminipage}
\end{boxedminipage}
\bigskip

\noindent Text after
\end{document}

Result:

enter image description here

This was adapted from How to use figure inside a minipage?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .