我试图弄清楚为什么在分段命令之后立即使用环境时,日志中没有图像和错误消息wrapfigure
。我能够强制wrapfigure
显示图像的唯一方法是在节标题和环境开头之间输入一些文本wrapfigure
——因此,我通过插入一个由一个不间断空格组成的段落并通过添加负数删除产生的空白行来获得我想要的结果\vspace
,我想这不是事情应该如何运作的方式。
有一段时间我以为我遇到了类似的问题章节标题下的换行图行为不当但如果我理解正确的话,那里的问题是由分页符引起的,而我的情况并非如此。
值得一提的是,我正在运行最新版本的 MiKTeX,但大约一年前我第一次遇到这个问题......
问题说明:
梅威瑟:
\documentclass[12pt]{article}
\usepackage[demo]{graphicx}
\usepackage[verbose]{wrapfig}
\begin{document}
%% Tight margins
\setlength{\intextsep}{0pt}
%% Does not work
\section*{Curricula Vitae}
%% Do not allow the figure to float away ...
\begin{wrapfigure}{l}{96pt}
%% ... but nevertheless this image does not show up.
\includegraphics[width=96pt,height=22pt]{example-image}
\end{wrapfigure}
\noindent
\textbf{Primum Author} condimentum augue id magna semper rutrum. Mauris elementum
mauris vitae tortor. Fusce suscipit libero eget elit. Nam quis nulla.
\section*{Working example}
%% Everything is okay if there is a paragraph of text between \section and
%% \begin{wrapfigure}. Adding the following line seems to solve my problem:
~\par\vspace{-\baselineskip}
%%
\begin{wrapfigure}{l}{96pt}
\includegraphics[width=96pt,height=22pt]{example-image}
\end{wrapfigure}
\noindent
\textbf{Primum Author} condimentum augue id magna semper rutrum. Mauris elementum
mauris vitae tortor. Fusce suscipit libero eget elit. Nam quis nulla.
\end{document}
有什么想法吗?我迫切地感觉到我错过了一些显而易见的东西。
编辑:@JohnKormylo 的评论让我再次查看了代码,经过一些额外的测试后,我非常确定这\noindent
是罪魁祸首。虽然
\section{...}
\begin{wrapfigure}...\end{wrapfigure}
\noindent
<paragraph text>
不会显示wrapfigure
环境的内容,在和\noindent
之间移动似乎有效。\section
\begin{wrapfigure}
知道为什么会这样吗?
答案1
您还可以使用普通的 TeX 宏包insbox
:
\documentclass[12pt]{article}
\usepackage[demo]{graphicx}
\usepackage[verbose]{wrapfig}
\input{insbox}
\begin{document}
%% Tight margins
\setlength{\intextsep}{0pt}
%% Does not work
\section*{Curricula Vitae}
%
\InsertBoxL{0}{\includegraphics[width=96pt,height=22pt]{example-image}}[-1]\noindent
\textbf{Primum Author} condimentum augue id magna semper rutrum. Mauris elementum
mauris vitae tortor. Fusce suscipit libero eget elit. Nam quis nulla.
\section*{Working example}
%% Everything is okay if there is a paragraph of text between \section and
%% \begin{wrapfigure}. Adding the following line seems to solve my problem:
~\par\vspace{-\baselineskip}
%%
\begin{wrapfigure}{l}{96pt}
\includegraphics[width=96pt,height=22pt]{example-image}
\end{wrapfigure}
\noindent
\textbf{Primum Author} condimentum augue id magna semper rutrum. Mauris elementum
mauris vitae tortor. Fusce suscipit libero eget elit. Nam quis nulla.
\end{document}