垂直环绕/居中文本

垂直环绕/居中文本

我需要包装一张图片。有一个地方的文字很短。因此,有一个相当重要的空白,这很糟糕。我需要“垂直居中”我的文本。我找不到怎么做...

这是 MME

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[francais]{babel}
\usepackage[T1]{fontenc}
\usepackage{wrapfig}
\usepackage{xcolor}
\usepackage[]{graphicx}
\usepackage{duckuments}
\usepackage{lipsum}

\title{Essai_wrapfigure}
\author{Donald Duck}
\date{June 2018}

\begin{document}

\maketitle
\tableofcontents
\chapter{Hello}
\section{Introduction}
\begin{wrapfigure}[10]{L}{0.3\textwidth}
\includegraphics[width=0.25\textwidth]{example-image-duck}
\end{wrapfigure}
A quite short text, no more lines unfortunately. There are about 35 words. We won't add more. Life is beautiful when you don't speak useless. Sometimes, it is better not to write too much.
\vspace{100pt}
\WFclear 
\section{Développement}
\begin{wrapfigure}[10]{L}{0.3\textwidth}
\includegraphics[width=0.25\textwidth]{example-image-duck}
\end{wrapfigure}
\lipsum[2-4]

\end{document}

结果 包裹图

段落“一段很短的文字……太多了”没有正确垂直居中。有办法吗?谢谢您的帮助。

答案1

这假设10\baselineskip为图形保留是一个错误。注意,如果您将宽度指定为 0pt,它将使用图像的宽度(加上\columnsep)。

设计\parbox为与图像高度相同,加上2\intextsep减去\baselineskip\intextsep由wrapfig 添加。[t]将的顶部\parbox与文本应放置的位置对齐。将[c]文本置于框内的中心。\WFclear需要,因为\parbox仅算作一行文本。

实验\fbox表明,这确实是以图像为中心的。

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[francais]{babel}
\usepackage[T1]{fontenc}
\usepackage{wrapfig}
\usepackage{xcolor}
\usepackage[]{graphicx}
\usepackage{duckuments}
\usepackage{lipsum}

\title{Essai wrapfigure}
\author{Donald Duck}
\date{June 2018}

\newsavebox{\mybox}

\begin{document}

\maketitle
\tableofcontents
\chapter{Hello}
\section{Introduction}\par
\savebox{\mybox}{\includegraphics[width=0.25\textwidth]{example-image-duck}}% measure height
\begin{wrapfigure}{L}{0.3\textwidth}
\usebox{\mybox}
\end{wrapfigure}
\noindent\parbox[t][\dimexpr \ht\mybox+2\intextsep-\baselineskip][c]{\linewidth}{\parindent=\bibindent
A quite short text, no more lines unfortunately. There are about 35 words. We won't add more. Life is beautiful when you don't speak useless. Sometimes, it is better not to write too much.}
\WFclear
\section{D\'eveloppement}% sorry, ascii here
\begin{wrapfigure}{L}{0.3\textwidth}
\includegraphics[width=0.25\textwidth]{example-image-duck}
\end{wrapfigure}
\lipsum[2-4]

\end{document}

相关内容