如何根据图像的高度使文本的垂直对齐居中?

如何根据图像的高度使文本的垂直对齐居中?

我尝试了 wrapfig 和 minipage,但是 wrapfig 导致冲突,而 minipages 没有正确地将文本置于图像的中心。

小型页面示例:

\documentclass[14pt,oneside]{memoir}
\usepackage{graphicx} % Insert image
\graphicspath{ {images/} }
\usepackage{wrapfig}
\usepackage{float}
\usepackage{lipsum}
\pagestyle{plain}

\begin{document}
\subsubsection{Step 1}
\begin{figure}[H]
    \centering
    \begin{minipage}{.22\textwidth}
        \centering
        \includegraphics[height=.2\textheight,width=1\linewidth]{example-image-a}
    \end{minipage}
    \begin{minipage}[t]{.76\textwidth}
        Very little text here. About a sentence or two... maybe three.
    \end{minipage}
\end{figure}

\subsubsection{Step 2}
\begin{figure}[H]
    \centering
    \begin{minipage}{.22\textwidth}
        \centering
        \includegraphics[height=.2\textheight,width=1\linewidth]{example-image-b}
    \end{minipage}
    \begin{minipage}[t]{.76\textwidth}
        \lipsum[66]
    \end{minipage}
\end{figure}

\subsubsection{Step 3}
\begin{figure}[H]
    \centering
    \begin{minipage}{.22\textwidth}
        \centering
        \includegraphics[height=.2\textheight,width=1\linewidth]{example-image-c}
    \end{minipage}
    \begin{minipage}[t]{.76\textwidth}
        \lipsum[75]
    \end{minipage}
\end{figure}
\end{document}

我得到了这个带有小页面的结果

虽然我想要这

答案1

用文本构建图像的另一种方法:使用tabularx,相应地重新定义列类型,您可以获得:

在此处输入图片描述

\documentclass[14pt,oneside]{memoir}
\usepackage{graphicx} % Insert image
\graphicspath{ {images/} }
\usepackage{wrapfig}
\usepackage{float}
\usepackage{lipsum}
\pagestyle{plain}

    \usepackage{tabularx}% <-- new
\renewcommand{\tabularxcolumn}[1]{>{\small}m{#1}}% <-- new
%    \usepackage{ragged2e}

\begin{document}
\subsubsection{Step 1}
    \begin{figure}[htb]
\begin{tabularx}{\textwidth}{>{\hsize=0.24\hsize\centering}X
                            >{\hsize=0.76\hsize}X}
\includegraphics[width=\hsize]{example-image-a}
    &
Very little text here. About a sentence or two... maybe three.
\end{tabularx}
    \end{figure}

\subsubsection{Step 2}
    \begin{figure}[htb]
\begin{tabularx}{\textwidth}{>{\hsize=0.24\hsize\centering}X
                            >{\hsize=0.76\hsize}X}
\includegraphics[width=\hsize]{example-image-b}
    &
\lipsum[66]
\end{tabularx}
    \end{figure}

\subsubsection{Step 3}
    \begin{figure}[htb]
\begin{tabularx}{\textwidth}{>{\hsize=0.24\hsize\centering}X
                            >{\hsize=0.76\hsize}X}
\includegraphics[width=\hsize]{example-image-c}
    &
\lipsum[75]
\end{tabularx}
    \end{figure}
\end{document}

答案2

在 B 中,你将图像的中心与文本的第一行对齐,这看起来很奇怪,只需删除它们[t]即可。

相关内容