我有一张包含多个子图的大图像,每个子图都已叠加自己的单字母标题。
我想从文本中引用这些子标题。据我所知,使用子标题及其幻影命令可以实现类似的功能,但我不确定它们是否涵盖了这种特殊情况。
有没有办法从回忆录中做到这一点?
这是一个示例图,可以更好地解释我想要做的事情
这是一张单一图像,我不想拆分它。我想引用子图像,因为它们是单独的图形。
编辑
如果我可以使用的话我会这样做subcaption
,不幸的是,当我使用回忆录自己的子图将其加载到文档中时,它就会弄乱所有的标题处理和样式。
所以问题仍然存在,有没有办法制作幻影字幕在回忆录中?
\documentclass{memoir}
\usepackage{subcaption}
\begin{document}
\begin{figure}[t]
\centering
\includegraphics{figure.png}
\begingroup
\phantomsubcaption
\label{fig:somefiga}
\phantomsubcaption
\label{fig:somefigb}
\phantomsubcaption
\label{fig:somefigc}
\phantomsubcaption
\label{fig:somefigd}
\endgroup
\caption{some caption}
\label{fig:somefig}
\end{figure}
\noindent Figure~\ref{fig:somefig} has four subfigures:
figure~\ref{fig:somefiga} is a nice fat rectangle, figure\ref{fig:somefigb}
looks good too. Figures~\ref{fig:somefigc}~and~\ref{fig:somefigd} could do
better.
\end{document}
答案1
据我所知,仅使用原生 Memoir 宏无法实现这一点。我自己的快速而粗糙的解决方案(绝对没有保证)是引入原始原生宏的略微修改版本(并排差异):
\documentclass[a4paper,14pt]{memoir}
\usepackage{graphicx}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=cyan,
}
\usepackage[all]{hypcap}
% =============== defining the \subcaptionphantom ===================================
\makeatletter
% \begin{macro}{\subcaptionphantom}
% \cs{subcaptionphantom}\oarg{list-entry}\marg{caption} is a hidden
% non-printed subcaption. Designed for the case if "(a)", "(b)" are
% already embedded in the figure itself.
% Roughtly equivalent to \cs{phantomsubcaption} from the \Lpack{subcaption} package.
%
% \begin{macrocode}
\newcommand{\subcaptionphantom}{%
\bgroup
\let\label=\memsub@label
\ifdonemaincaption\else
\advance\csname c@\@captype\endcsname\@ne
\fi
\refstepcounter{sub\@captype}\@contkeep
\@ifnextchar [%
{\@memsubcapphantom{sub\@captype}}%
{\@memsubcapphantom{sub\@captype}[\@empty]}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@memsubcapphantom}
% Quick-and-dirty analog of \Lpack{memoir} \cs{memsubcap}, adapted
% for use in \cs{subcaptionphantom}.
% \begin{macrocode}
\long\def\@memsubcapphantom#1[#2]#3{%
\@tempdima=\hsize
\vskip\subfloatcapskip
\ifx \@empty #2
\@memsubcaptionphantom{#1}{#3}{#3}%
\else
\@memsubcaptionphantom{#1}{#2}{#3}%
\fi
\vskip\subfloatcapskip
\egroup}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@memsubcaptionphantom}
% Quick-and-dirty analog of \Lpack{memoir} \cs{memsubcaption}, adapted
% for use in \cs{memsubcapphantom}.
% \begin{macrocode}
\newcommand{\@memsubcaptionphantom}[3]{%
\ifx \relax#2\relax \else
\bgroup
\let\label\@gobble
\let\protect\string
\def\@memsubcaplabel{\@nameuse{@@the#1}}%
\xdef\@memsubfigcaptionlist{%
\@memsubfigcaptionlist,%
{\protect\numberline{\@memsubcaplabel}\noexpand{\ignorespaces #2}}}%
\egroup
\fi
\@makesubfloatcaptionphantom{\@nameuse{@the#1}}{#3}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@makesubfloatcaptionphantom}
% Quick-and-dirty analog of \Lpack{memoir} \cs{makesubfloatcaption}, adapted
% for use in \cs{memsubcaptionphantom}.
% \begin{macrocode}
\newcommand{\@makesubfloatcaptionphantom}[2]{%
\setbox\@tempboxa\hbox{%
\@subcapsize
{\phantom{\@subcaplabelfont#1}}{\ignorespaces #2}\unskip}%
\@tempdimb=-\subfloatcapmargin
\multiply\@tempdimb\tw@
\advance\@tempdimb\@tempdima
\hb@xt@\@tempdima{%
\hss
\ifdim \wd\@tempboxa >\@tempdimb
\phantom{\memsubfig@caption{#1}}{#2}%
\else
\if@shortsubcap
\phantom{\memsubfig@caption{#1}}{#2}%
\else
\box\@tempboxa
\fi
\fi
\hss}}
% \end{macrocode}
% \end{macro}
\makeatother
% ===================================================================================
\newsubfloat{figure} % allows to use "subbottom"
\begin{document}
\begin{figure}
\centering
\hfill%
\begin{minipage}[b][][b]{0.6\linewidth}
\centering
\subcaptionphantom{\label{sf:1}}
\subcaptionphantom{\label{sf:2}}
\framebox[\linewidth]{\textit{subfigure with embedded (a)}}
\framebox[\linewidth]{\textit{subfigure with embedded (b)}}
\end{minipage}
\hfill%
\begin{minipage}{0.3\linewidth}
\centering
\subbottom[regular subfigure \label{sf:3}]%
{\includegraphics[width=0.7\linewidth]{example-image}}
\end{minipage}
\caption{Figure with three subfigures\label{fig:1}}
\end{figure}
Example refs:\newline
Full fig: \ref{fig:1}. \newline
Sub1: \subcaptionref{sf:1}, same as \ref{sf:1} (the hidden caption). \newline
Sub2: \subcaptionref{sf:2}, same as \ref{sf:2} (the hidden caption). \newline
Sub3: \subcaptionref{sf:3}, same as \ref{sf:3}. \newline
\clearpage
This text is here to add more space for scrolling.
\end{document}