4

What is the way to control alignment of subfloats (by content or by subcaption)? Some memoir or \xpatchcmd hack maybe?

MWE (slight modification of Hyperref not jumping to the appropriate location for memoir's subbottom):

% !TeX program = pdflatex
\listfiles
\documentclass[a4paper,14pt,oneside,openany]{memoir}
\usepackage{graphicx}
\usepackage{hyperref}
%\usepackage[all]{hypcap}

\newsubfloat{figure} % allows to use "subbottom"

\begin{document}
This link jumps to the figure caption: \ref{fig:1}.

This link jumps to the picture (the way I like): \ref{sf:11}. 

This link should jump to the picture: \ref{sf:12}. % Same with \subcaptionref{sf:12}.

This link should jump to the picture: \subcaptionref{sf:13}. % Same with \ref{sf:13}.

This link jumps to the picture (the way I like): \ref{sf:14}.

This link should jump to the picture: \ref{sf:15}.

\begin{figure}
    \centerfloat{
    % \hfill  %  uncommenting this line makes link to sf:11 jump to incorrect vertical position as well. Why?
    \subbottom[Subfigure 1\label{sf:11}]{\includegraphics[width=0.35\linewidth]{example-image-a}}
    \hfill
    \subbottom[Subfigure 2\label{sf:12}]{\includegraphics[width=0.25\linewidth]{example-image-b}}
    \hfill
    \subbottom[\label{sf:13}Subfigure 3 multilined caption]{\includegraphics[width=0.25\linewidth]{example-image-c}}
    \\
    \subbottom[Subfigure 4\label{sf:14} multilined caption]{\includegraphics[width=0.33\linewidth]{example-image-b}}
    \hfill
    \subbottom[\label{sf:15}Subfigure 5]{\includegraphics[width=0.3\linewidth]{example-image-a}}
    }
    \legend{Some legend. This text is here to add more space for multilining.
    This text is here to add more space for multilining.}
    \caption{Figure with five subfigures\label{fig:1}}
\end{figure}        


\clearpage

Now check subtops.

This link jumps to the figure caption: \ref{fig:2}.

This link jumps to the top of the subcaption (the way I like): \ref{sf:21}. 

This link should jump to the top of the subcaption: \ref{sf:22}. % Same with \subcaptionref{sf:12}.

This link should jump to the top of the subcaption: \subcaptionref{sf:23}. % Same with \ref{sf:13}.

This link jumps to the top of the subcaption (the way I like): \ref{sf:24}.

This link should jump to the top of the subcaption: \ref{sf:25}.

\begin{figure}
    \centerfloat{
    % \hfill  %  uncommenting this line makes link to sf:11 jump to incorrect vertical position as well. Why?
    \subtop[Subfigure 1\label{sf:21}]{\includegraphics[width=0.35\linewidth]{example-image-a}}
    \hfill
    \subtop[Subfigure 2\label{sf:22}]{\includegraphics[width=0.25\linewidth]{example-image-b}}
    \hfill
    \subtop[\label{sf:23}Subfigure 3 multilined caption]{\includegraphics[width=0.25\linewidth]{example-image-c}}
    \\
    \subtop[Subfigure 4\label{sf:24} multilined caption]{\includegraphics[width=0.33\linewidth]{example-image-b}}
    \hfill
    \subtop[\label{sf:25}Subfigure 5]{\includegraphics[width=0.3\linewidth]{example-image-a}}
    }
    \legend{Some legend. This text is here to add more space for multilining.
    This text is here to add more space for multilining.}
    \caption{Figure with five subfigures\label{fig:2}}
\end{figure}  

\clearpage
This text is here to add more space for scrolling.

\end{document}

Subbottom result (TL2019 updated on 2020-01-18, Memoir v3.7j) — aligned by bottom of subcaptions (but i would like it to be the bottom of figures): Subbottom result (TL2019 updated on 2020-01-18, Memoir v3.7j)

Subtop result (TL2019 updated on 2020-01-18, Memoir v3.7j) — aligned by bottom of figures (but i would like it to be the top of subcaptions or maybe the top of figures): Subtop result (TL2019 updated on 2020-01-18, Memoir v3.7j)

Subbottom result (TL2018 fully updated, Memoir v3.7h) — seems like correct subbottom alignment: Subbottom result (TL2018 fully updated, Memoir v3.7h)

Subtop result (TL2018 fully updated, Memoir v3.7h) — seems like good subtop alignment: Subtop result (TL2018 fully updated, Memoir v3.7h)

It would be great if there is a workaround that will work for both versions of memoir (together with \xpatchcmd solution for hyperref linking from https://tex.stackexchange.com/a/466515).

15
  • 5
    @NeilG And I stand by that statement. In this case you have better support by going with the caption package and friends. Stuff like this leads to alignment nightmares especially when you also have to combine it with hyperref targets. The caption package and its friends have already solved this problem. I maintain memoir and regularly use caption with memoir as it has more features than what memoir will ever support out of the box.
    – daleif
    Commented Feb 15, 2020 at 13:11
  • 1
    @daleif Thank you for the fast reply, Professor Madsen. I wrongly figured I should stick to the included memoir packages. I will switch to caption as you suggest. I'm just curious: why not include caption in memoir if it's so much better?
    – Neil G
    Commented Feb 16, 2020 at 10:28
  • 1
    @NealG have you seen the size of the code? We could switch to loading caption but that would probably affect existing documents. Things were different back when Peter Wilson made the class. It was hard updating, manuals were not always available. So the memoir philosophy is more in the realm of a lot of stuff already being available, so that you don't need so many packages that you used to. But also being made such that certain powerful packages still work with the class
    – daleif
    Commented Feb 16, 2020 at 10:35
  • 1
    @NealG if we started today, we'd probably throw out a lot of stuff from the class, and get a lot of stuff from there powerful packages like caption, subcaption and enumitem. But other stuff would still be made in a way what is integraler into each other
    – daleif
    Commented Feb 16, 2020 at 10:37
  • 3
    @NealG it depends on the project. It is the same reason why I do not provide templates to students. Different documents have different needs. Some only need normal captions and never need to adjust them, others need supcaptions (keeps them short and explain them 7n the primary caption or in the text). Enumitem is always an auto include for me, plus some math packages. I rarely write my own stuff these days, I mostly edit/clean other people's stuff. Besides, since things are easier to update, there are stuff that are no longer embedded into memoir, like array, textcase etc.
    – daleif
    Commented Feb 16, 2020 at 11:07

0

You must log in to answer this question.

Browse other questions tagged .