仅对齐部分子图

仅对齐部分子图

请考虑以下示例:

\documentclass{article}

\usepackage{pstricks-add}
\usepackage{subcaption}
\usepackage{siunitx}

\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff

\newcommand*\diagonalcm{\calc{round(\diagonaltomme*2.54,1)}}
\newcommand*\katete[1]{\calc{sqrt(\diagonalcm^2-#1^2)}}
\def\Label(#1)(#2)#3{%
  \pcline[linestyle = none, offset = 7pt](#1)(#2)
  \ncput*[nrot = :U]{\SI{\calc{round(#3,1)}}{\cm}}}
\newcommand*\rektangel[3]{%
\begin{subfigure}{0.4\textwidth}
 \centering
  \begin{pspicture}(0,0)(\katete{#1},#1)
    \Label(\katete{#1},0)(\katete{#1},#1){#1}
    \Label(0,0)(\katete{#1},0){\katete{#1}}
    \Label(0,0)(\katete{#1},#1){\diagonalcm}
    \psframe(0,0)(\katete{#1},#1)
    \psline[linestyle = dashed](0,0)(\katete{#1},#1)
  \end{pspicture}
 \subcaption{#2 rektangel.}
 \label{#3}
\end{subfigure}}

\begin{document}

\def\diagonaltomme{4.0}
\def\kateteA{5}
\def\kateteB{6}

\begin{figure}
\psset{unit = 0.54}
 \centering
   \rektangel{\kateteA}{F{\o}rste}{fig:1a}
  \qquad \textnormal{og} \qquad
   \rektangel{\kateteB}{Andet}{fig:1b}
 \caption{Forskellige rektangler med $d = \SI{\diagonalcm}{\cm}$.}
 \label{fig:1}
\end{figure}

\end{document}

输出

subfigure我知道如何通过给环境选项来对齐底部的两个矩形[b],但如何对齐两个图形并og同时垂直居中?

答案1

使用\subcaptionbox来自subcaption包裹:

% arara: latex
% arara: dvips
% arara: ps2pdf

\documentclass{article}

\usepackage{pstricks-add}
\usepackage{subcaption}
\usepackage{siunitx}

\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff

\newcommand*\diagonalcm{\calc{round(\diagonaltomme*2.54,1)}}
\newcommand*\katete[1]{\calc{sqrt(\diagonalcm^2-#1^2)}}
\def\Label(#1)(#2)#3{%
  \pcline[linestyle = none, offset = 7pt](#1)(#2)
  \ncput*[nrot = :U]{\SI{\calc{round(#3,1)}}{\cm}}}
\newcommand*\rektangel[3]{%
\subcaptionbox{#2 rektangel.\label{#3}}{%
  \begin{pspicture}(0,0)(\katete{#1},#1)
    \Label(\katete{#1},0)(\katete{#1},#1){#1}
    \Label(0,0)(\katete{#1},0){\katete{#1}}
    \Label(0,0)(\katete{#1},#1){\diagonalcm}
    \psframe(0,0)(\katete{#1},#1)
    \psline[linestyle = dashed](0,0)(\katete{#1},#1)
  \end{pspicture}}%
}

\begin{document}

\def\diagonaltomme{4.0}
\def\kateteA{5}
\def\kateteB{6}

\begin{figure}
\psset{unit = 0.54}
 \centering
   \rektangel{\kateteA}{F{\o}rste}{fig:1a}
  \qquad \raisebox{.54\dimexpr\kateteA cm/2\relax}{\textnormal{og}} \qquad
   \rektangel{\kateteB}{Andet}{fig:1b}
 \caption{Forskellige rektangler med $d = \SI{\diagonalcm}{\cm}$.}
 \label{fig:1}
\end{figure}

\end{document}

在此处输入图片描述

相关内容