\documentclass{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{duckuments}
\newsubfloat{figure}
\begin{document}
\begin{figure}
\centerfloat
\begin{minipage}{10cm}
\subbottom[huey]{\includegraphics[width=10cm]{example-image-duck}}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\subtop[duey]{\includegraphics[width=5cm]{example-image-duck}}
\subbottom[luey]{\includegraphics[width=5cm]{example-image-duck}}
\end{minipage}
\caption{Donalds nephews}
\label{fig:nephew}
\end{figure}
\end{document}
但是由于第一个图形的宽度未知,所以我无法制作小页面,然后我得到:
使用 MWE 制作:
\documentclass{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{duckuments}
\newsubfloat{figure}
\begin{document}
\begin{figure}
\centerfloat
% \begin{minipage}{10cm}
\subbottom[huey]{\includegraphics[width=10cm]{example-image-duck}} %The 10 cm is unknown
% \end{minipage}
\begin{minipage}{0.5\textwidth}
\subtop[duey]{\includegraphics[width=5cm]{example-image-duck}}
\subbottom[luey]{\includegraphics[width=5cm]{example-image-duck}}
\end{minipage}
\caption{Donalds nephews}
\label{fig:nephew}
\end{figure}
\end{document}
有没有办法从命令中找到宽度\includegraphics
,或者在没有小页面的情况下对齐图形?
答案1
这是计算所需宽度的建议。我pgf
在这里使用它来使计算更易于理解,原则上可以将其剥离。也可以修改内容以尊重标题的高度,但这是基本的计算。
\documentclass{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{duckuments}
\newsubfloat{figure}
\usepackage{pgf}
\begin{document}
We are given the aspect ratios $r_i$ of three figures, $r_i$. Let's call their
final heights $y_i$ and widths $x_i$, i.e.\ $r_i=y_i/x_i$. We want the sum
of heights of figures 2 and 3 to coincide with the height of figure 1,
\[y_2+y_3=r_2x_2+r_3x_3=x_2(r_2+r_3)\stackrel{!}{=}y_1=r_1x_1\;,\]
where we have used that figures 2 and 3 should be equally wide, $x_2=x_3$. We
also want the width of figures 1 and 2 (or, equivalently, 1 and 3) to add up to
some target width $t$, $x_1+x_2=t$. Therefore
\[ x_1=\frac{r_2+r_3}{r_1+r_2+r_3}t\;.\]
The following example uses $t=0.95$\textbackslash\texttt{textwidth}. In
this version, the heights of the captions have not been taken into account.
% in general the ratios may not coincide
\pgfmathsetmacro{\rOne}{height("\includegraphics{example-image-duck}")/width("\includegraphics{example-image-duck}")}
\pgfmathsetmacro{\rTwo}{height("\includegraphics{example-image-duck}")/width("\includegraphics{example-image-duck}")}
\pgfmathsetmacro{\rThree}{height("\includegraphics{example-image-duck}")/width("\includegraphics{example-image-duck}")}
\pgfmathsetmacro{\xOne}{((\rOne+\rTwo)/(\rOne+\rTwo+\rThree))*0.95*\textwidth}
\pgfmathsetmacro{\xTwo}{0.95*\textwidth-\xOne}
\begin{figure}
\centerfloat
\begin{minipage}{\xOne pt}
\subbottom[huey]{\includegraphics[width=\xOne pt]{example-image-duck}}
\end{minipage}
\begin{minipage}{\xTwo pt}
\subtop[duey]{\includegraphics[width=\xTwo pt]{example-image-duck}}
\subbottom[luey]{\includegraphics[width=\xTwo pt]{example-image-duck}}
\end{minipage}
\caption{Donalds nephews}
\label{fig:nephew}
\end{figure}
\clearpage
Assume now that we want to take into account the caption heights. For
simplicity, assume they are universal and denote them by $h$. More precisely, at
this level $h$ is a tuning parameter that can be adjusted to account for the
captions. Then
\[2h+y_2+y_3=2h+r_2x_2+r_3x_3=2h+x_2(r_2+r_3)\stackrel{!}{=}h+y_1=h+r_1x_1\]
and thus
\[ x_1=\frac{(r_2+r_3)t+h}{r_1+r_2+r_3}\;.\]
\pgfmathsetmacro{\rOne}{height("\includegraphics{example-image-duck}")/width("\includegraphics{example-image-duck}")}
\pgfmathsetmacro{\rTwo}{height("\includegraphics{example-image-duck}")/width("\includegraphics{example-image-duck}")}
\pgfmathsetmacro{\rThree}{height("\includegraphics{example-image-duck}")/width("\includegraphics{example-image-duck}")}
\pgfmathsetmacro{\hCaption}{17.5} %<-just a guess
\pgfmathsetmacro{\xOne}{(((\rOne+\rTwo)*0.95*\textwidth+\hCaption)/(\rOne+\rTwo+\rThree))}
\pgfmathsetmacro{\xTwo}{0.95*\textwidth-\xOne}
\begin{figure}
\centerfloat
\begin{minipage}{\xOne pt}
\subbottom[huey]{\includegraphics[width=\xOne pt]{example-image-duck}}
\end{minipage}
\begin{minipage}{\xTwo pt}
\subtop[duey]{\includegraphics[width=\xTwo pt]{example-image-duck}}
\subbottom[luey]{\includegraphics[width=\xTwo pt]{example-image-duck}}
\end{minipage}
\caption{Donalds nephews}
\label{fig:nephewtuned}
\end{figure}
\end{document}
我还添加了一种考虑标题的方法(但这需要调整,因为我不知道他们到底做了什么\subbottom
,\subtop
即他们使用了哪些维度。如果知道这一点,下面的讨论可能会允许人们计算h
而不是猜测。
答案2
\documentclass{memoir}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{duckuments}
\newsubfloat{figure}
\usepackage{showframe}
\begin{document}
\begin{figure}
\centerfloat
\begin{minipage}{8cm}
\strut\\
\subbottom[huey]{\includegraphics[width=\linewidth]{example-image-duck}}
\end{minipage}\quad
\begin{minipage}{\dimexpr\textwidth-8cm-1em}
\subtop[duey\strut]{\includegraphics[width=\linewidth]{example-image-duck}}
\subbottom[luey\strut]{\includegraphics[width=\linewidth]{example-image-duck}}
\end{minipage}
\caption{Donalds nephews}\label{fig:nephew}
\end{figure}
\end{document}