![如何根据图像的高度使文本的垂直对齐居中?](https://linux22.com/image/333582/%E5%A6%82%E4%BD%95%E6%A0%B9%E6%8D%AE%E5%9B%BE%E5%83%8F%E7%9A%84%E9%AB%98%E5%BA%A6%E4%BD%BF%E6%96%87%E6%9C%AC%E7%9A%84%E5%9E%82%E7%9B%B4%E5%AF%B9%E9%BD%90%E5%B1%85%E4%B8%AD%EF%BC%9F.png)
我尝试了 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]
即可。