更新

更新

我想使用左边距的条形图来指示段落中文本的一部分。我希望有类似以下示例的效果,但没有换行符,并且文本换行,就像没有侧边线一样。

\documentclass{article}
\usepackage{mdframed}

\newmdenv[
  topline=false,
  bottomline=false,
  rightline=false,
  skipabove=\topsep,
  skipbelow=\topsep,
  leftmargin=-10pt,
  rightmargin=-10pt,
  innertopmargin=0pt,
  innerbottommargin=0pt
]{siderules}

\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\begin{siderules}
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{siderules}
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

\end{document}

答案1

这是一个选项:

\documentclass{article}
\usepackage{refcount}
\usepackage{tikzpagenodes}

\newcounter{tmp}
\newcommand\tikzmark[1]{%
  \tikz[overlay,remember picture] \node (#1) {};}

\newcommand\StartRule{%
  \stepcounter{tmp}%
  \tikzmark{a}\label{a\thetmp}%
  \ifnum\getpagerefnumber{a\thetmp}=\getpagerefnumber{b\thetmp} \else
  \begin{tikzpicture}[overlay, remember picture]
    \draw[ultra thick,gray]
      ([xshift=-10pt,yshift=1.5ex]a-|current page text area.west) --  ([xshift=-10pt]current page text area.south west);
  \end{tikzpicture}%
  \fi%
}

\newcommand\EndRule{%
\tikzmark{b}\label{b\thetmp}
  \ifnum\getpagerefnumber{a\thetmp}=\getpagerefnumber{b\thetmp}
  \begin{tikzpicture}[overlay, remember picture]
    \draw [ultra thick,gray]
      ([xshift=-10pt,yshift=1.5ex]a-|current page text area.west) -- ([xshift=-10pt]b-|current page text area.west);
  \end{tikzpicture}%
  \else
  \begin{tikzpicture}[overlay, remember picture]
    \draw [ultra thick,gray]
      ([xshift=-10pt]current page text area.north west) -- ([xshift=-10pt]b-|current page text area.west);
  \end{tikzpicture}%
  \fi
}

\newcommand\LRule[1]{\StartRule#1\EndRule}

\begin{document}

Some test text and here we add some more text just for the example with some more words some more text just for the example with some more words some more text just for the example \StartRule and here we add some more text just for the example with some more words some more text just for the example with some more words some more text just for the example with some more words some more text just for the example with some more words \EndRule and here we add some more text just for the example with some more words some more text just for the example with some more words some more text just for the example and here we add some more text just for the example with some more words some more text just for the example with some more words some more text just for the example

\end{document}

在此处输入图片描述

使用\StartRule <text>\EndRule\LRule{<text>}。它允许分页。

更新

它适用于wrapfig

\documentclass{article}
\usepackage{wrapfig}
\usepackage{refcount}
\usepackage{graphicx}
\usepackage{tikzpagenodes}

\newcounter{tmp}
\newcommand\tikzmark[1]{%
  \tikz[overlay,remember picture] \node (#1) {};}

\newcommand\StartRule{%
  \stepcounter{tmp}%
  \tikzmark{a}\label{a\thetmp}%
  \ifnum\getpagerefnumber{a\thetmp}=\getpagerefnumber{b\thetmp} \else
  \begin{tikzpicture}[overlay, remember picture]
    \draw[ultra thick,gray]
      ([xshift=-10pt,yshift=1.5ex]a-|current page text area.west) --  ([xshift=-10pt]current page text area.south west);
  \end{tikzpicture}%
  \fi%
}

\newcommand\EndRule{%
\tikzmark{b}\label{b\thetmp}
  \ifnum\getpagerefnumber{a\thetmp}=\getpagerefnumber{b\thetmp}
  \begin{tikzpicture}[overlay, remember picture]
    \draw [ultra thick,gray]
      ([xshift=-10pt,yshift=1.5ex]a-|current page text area.west) -- ([xshift=-10pt]b-|current page text area.west);
  \end{tikzpicture}%
  \else
  \begin{tikzpicture}[overlay, remember picture]
    \draw [ultra thick,gray]
      ([xshift=-10pt]current page text area.north west) -- ([xshift=-10pt]b-|current page text area.west);
  \end{tikzpicture}%
  \fi
}

\newcommand\LRule[1]{\StartRule#1\EndRule}

\begin{document}

\begin{wrapfigure}{r}{.4\textwidth}
\includegraphics[width=\linewidth]{example-image-a}
\end{wrapfigure}
Some test text and here we add some more text just for the example with some more words some more text just for the example with some more words some more text just for the example \StartRule and here we add some more text just for the example with some more words some more text just for the example with some more words some more text just for the example with some more words some more text just for the example with some more words \EndRule and here we add some more text just for the example with some more words some more text just for the example with some more words some more text just for the example and here we add some more text just for the example with some more words some more text just for the example with some more words some more text just for the example

\end{document}

在此处输入图片描述

相关内容