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"?

Mark T
  • 5
  • 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? – Torbjørn T. Oct 28 '16 at 15:28
  • Google for lifecon.sty, and go to Eddy Trivet's page: http://www.unalmed.edu.co/~ndgirald/Archivos%20Lectura/Archivos%20curso%20Actuaria/lifecon.sty – Mark T Oct 28 '16 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 '16 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. – Torbjørn T. Oct 28 '16 at 15:53
  • I'll have to build a MWE and post it here -- but that will be a couple of hours away cos' I'm just about to drive home. The error appears when compiling in MikTex, I have not looked at the code in life con (or any other package - I don't know how Latex works), so I don't know what info there is to is not. You could be right about the package -- I was typing this question from memory. I actually took the example from 229440 and placed it in my code, so I did have precisely what's in that example. – Mark T Oct 28 '16 at 15:58
  • Ah - a thought about the MWE... how can I get it onto the page (given that comments are only 600 chars +/-) ? – Mark T Oct 28 '16 at 16:04
  • 1
    Edit your question (there should be a link just between question and comments), comments are really not the place for blocks of code. – Torbjørn T. Oct 28 '16 at 16:09
  • If this conversation is moved to chat, how will I know where to find it? – Mark T Oct 28 '16 at 16:10
  • There will be a link to the chatroom if you choose to do that, but I don't think it's necessary. Just make the MWE and update the question when you've done that. – Torbjørn T. Oct 28 '16 at 16:13

2 Answers2

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?

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

Werner
  • 603,163
  • I have updated your template to show what I need. – Mark T Oct 28 '16 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 '16 at 19:22
  • until the edit becomes visible to all, I added $\lcEnd{A}{x}{n}$ after \begin{document} – Mark T Oct 28 '16 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 '16 at 19:53
  • @MarkT: I've updated my answer to correct the way the subcaption counter was resetting. – Werner Oct 29 '16 at 00:11