使用 picinpar 包时段落缩进不正确

使用 picinpar 包时段落缩进不正确

我正在使用该picinpar软件包,但不知道为什么段落缩进不起作用。问题单词已突出显示:

在此处输入图片描述

笔记:

  • 我并不一定要使用该picinpar软件包,但想要避免必须在插入点指定图形的宽度。提供的示例使用\includegraphicsMWE 保持简单,但我的图形是tikz图形,所以我使用最容易使用的\input“\includegraphics picinpar”。in my real use case. I tried the other solutions at the references question, and found
  • 我想也许问题在于,\parskip我们在环境\parindent中休息window为什么 \parskip 在小页面中为零?,但该解决方案(注释掉)没有效果。
  • 如果使用该包,这个工作会很好parskip,但我试图使用推荐的缩进段落。

参考:

代码:

\documentclass{article}
%\usepackage{parskip}% Works great with this.
\usepackage[demo]{graphicx}
\usepackage{picinpar}
\usepackage{showframe}
\usepackage{lipsum}
\usepackage{xcolor}% To highlight problem text

\newlength{\currentparskip}
\newlength{\currentparindent}
\newcommand{\MyWrapFig}[3][]{%
    % #1 = options: number of lines, align
    % #2= figure content
    % #3= text content
    %
    %\setlength{\currentparskip}{\parskip}% save the value
    %\setlength{\currentparindent}{\parindent}% save the value
    %
    \begin{window}[#1, #2,]
        %\setlength{\parskip}{\currentparskip}% restore the value
        %\setlength{\parindent}{\currentparindent}% restore the value
        #3%
    \end{window}
}%

\newcommand{\SomeMoreText}{Some text. Some more text.}%
\newcommand{\Text}{%
    \SomeMoreText   \SomeMoreText   \SomeMoreText
    \SomeMoreText   \SomeMoreText   \SomeMoreText
}%


\begin{document}
\section{First Section}
\MyWrapFig[1,r]{%
    \includegraphics[height=1cm]{MyFigure}
}{%
    \textcolor{red}{Here} is a paragraph that should \emph{not} be indented without parskip.
    \SomeMoreText

    \textcolor{red}{This} is the second paragraph which \emph{should} be indented without parskip.
    \SomeMoreText \SomeMoreText \SomeMoreText

    \textcolor{red}{Last} paragraph that \emph{should} also be indented without parskip.
    \Text
}

\MyWrapFig[1,r]{%
    \includegraphics[width=3cm]{MyFigure}
}{%
    Here is a paragraph that should be indented without parskip.
    \SomeMoreText

    \textcolor{red}{This} is the second paragraph which \emph{should} be indented without parskip.
    \SomeMoreText

    \textcolor{red}{Last} paragraph that \emph{should} also be indented without parskip.
    \Text
}
\end{document}

答案1

这不是一个完整的解决方案,但也许有帮助。它实现了:

  • 需要缩进的段落自动缩进;
  • 您不需要指定插入东西的宽度。

它未能实现的是:

  • 分段之后的第一段\noindent如需环绕插入内容,则必须标有;

存在一些单词溢出的问题,导致框过满。感谢Peter Grill 的评论注意到的力量microtype解决了这个问题。

通过添加\noindent,我自动获得此输出:

文本围绕插入的内容流动

代码:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{showframe}
\usepackage{lipsum}
\usepackage{xcolor}% To highlight problem text
\newcommand{\SomeMoreText}{Some text. Some more text.}%
\newcommand{\Text}{%
    \SomeMoreText   \SomeMoreText   \SomeMoreText
    \SomeMoreText   \SomeMoreText   \SomeMoreText
}
\usepackage{microtype}
\input{insbox}

\begin{document}
  \section{First Section}
  \InsertBoxR{1}{\includegraphics[height=1cm]{MyFigure}}
  \noindent\textcolor{red}{Here} is a paragraph that should \emph{not} be indented without parskip.
  \SomeMoreText

  \textcolor{red}{This} is the second paragraph which \emph{should} be indented without parskip.
  \SomeMoreText \SomeMoreText \SomeMoreText

  \textcolor{red}{Last} paragraph that \emph{should} also be indented without parskip.
  \Text

  \InsertBoxR{1}{\includegraphics[width=3cm]{MyFigure}}
  Here is a paragraph that should be indented without parskip.
  \SomeMoreText

  \textcolor{red}{This} is the second paragraph which \emph{should} be indented without parskip.
  \SomeMoreText

  \textcolor{red}{Last} paragraph that \emph{should} also be indented without parskip.
  \Text

\end{document}

相关内容