如何使用 mdframed 跨页面更改文本颜色

如何使用 mdframed 跨页面更改文本颜色

考虑以下 MWE:

\documentclass[twoside, a4paper, 12pt]{article}
\usepackage{amsmath, amssymb}
\usepackage[framemethod=TikZ]{mdframed}


\linespread{1.5}

\usepackage[top=0.85in, bottom=0.85in, left=0.85in, right=0.85in]{geometry}

\raggedbottom


\begin{document}


\begin{center}
\textbf{Title:}

\textbf{Hello I am a title}
\end{center}

\begin{mdframed}
\setcounter{mpfootnote}{\value{footnote}}
\renewcommand{\thempfootnote}{\arabic{mpfootnote}}

\renewcommand{\thesection}{4}
\section{Section title}

Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color.

Start this paragraph off with some text. \textcolor{red}{This is the part of the text I want to change to red but it breaks when there is a new page.}

\textcolor{green}{Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color. Let's fill up the space with text and see what happens when we change the color.} 


\end{mdframed}

\end{document}

出于某种原因,当我尝试将一段文本更改为不同的颜色时,页面在句子中间更改时会中断。例如,红色文本在第 1 页上是红色,但在第 2 页上又变回黑色。但绿色文本完全变为绿色,因为它没有跨越两个不同的页面。

在此处输入图片描述 在此处输入图片描述

我怎样才能防止这种情况发生,以便红色文本即使跨越多页也完全是红色的?

相关内容