自定义 \newenvironment{pullquote} 不起作用

自定义 \newenvironment{pullquote} 不起作用

我正在尝试定义一个自\newenvironment定义的引文。如果没有,environment它会按如下方式运行: 

\documentclass[12pt,a4paper]{article}   
\usepackage{lipsum}
\usepackage{Archivo}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{sectsty}
\usepackage{xcolor}
\usepackage{tcolorbox}

%%%%pullquote%%%%
\definecolor{colorquote}{HTML}{e8e9f5}
\newtcolorbox{myquote{colback=colorquote,colframe=colorquote,arc=0pt,outer arc=0pt}


\DeclareUnicodeCharacter{202F}{\,}
\usepackage[colorlinks,hidelinks,urlcolor=blue,bookmarks=false,hypertxnames=true]{hyperref} 
\usepackage[notes,autocite=footnote,backend=biber,natbib=true,sorting=nyt,]{biblatex-chicago}
\ExecuteBibliographyOptions{maxcitenames=1}

\DeclareFieldFormat{citehyperref}{%
    \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
    \bibhyperref{#1}}
\savebibmacro{cite}
\renewbibmacro*{cite}{%
    \printtext[citehyperref]{%
        \restorebibmacro{cite}%
        \usebibmacro{cite}}}



\addbibresource{}
\author{}
\title{\color[RGB]{40,39,129,255}\textbf{Title}}
\begin{document}
    \maketitle
    
\lipsum[1]
    \begin{wrapfigure}{r}{0.35\textwidth}
        \begin{myquote}
            content for pull quote
        \end{myquote}
    \end{wrapfigure}
\lipsum*[3]
    
\end{document}

在此处输入图片描述

但是当我尝试创建它时,\newenvironment它给出了:

在此处输入图片描述

\documentclass[12pt,a4paper]{article}   
\usepackage{lipsum}
\usepackage{Archivo}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{sectsty}
\usepackage{xcolor}
\usepackage{tcolorbox}



%%%%%section fonts%%%%
\sectionfont{\color[HTML]{282781}}
\subsectionfont{\color[HTML]{282781}}

%%%%pullquote%%%%
\definecolor{colorquote}{HTML}{e8e9f5}
\newtcolorbox{myquote}{colback=colorquote, colframe=colorquote,arc=0pt,outer arc=0pt}

\newenvironment{pullquote}
    {\begin{wrapfigure}{r}{0.35\textwidth}
        \begin{myquote}
        \end{myquote}
    \end{wrapfigure}
    }


\DeclareUnicodeCharacter{202F}{\,}
\usepackage[colorlinks,hidelinks,urlcolor=blue,bookmarks=false,hypertexnames=true]{hyperref} 
\usepackage[notes,autocite=footnote,backend=biber,natbib=true,sorting=nyt,]{biblatex-chicago}
\ExecuteBibliographyOptions{maxcitenames=1}

\DeclareFieldFormat{citehyperref}{%
    \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
    \bibhyperref{#1}}
\savebibmacro{cite}
\renewbibmacro*{cite}{%
    \printtext[citehyperref]{%
        \restorebibmacro{cite}%
        \usebibmacro{cite}}}



\addbibresource{}
\author{Louis Vigneras}
\title{\color[RGB]{40,39,129,255}\textbf{Title}}
\begin{document}
    \maketitle
    
\lipsum[1]

\begin{pullquote}
    content for pull quote.
\end{pullquote}

\lipsum*[3]
    
\end{document}

PS 我保留了其他包,以防出现包冲突的问题。

答案1

\newenvironment{pullquote}
    {\begin{wrapfigure}{r}{0.35\textwidth}
        \begin{myquote}
        \end{myquote}
    \end{wrapfigure}
    }

\newenvironment{pullquote}
    {\begin{wrapfigure}{r}{0.35\textwidth}
        \begin{myquote}
        \end{myquote}
    \end{wrapfigure}
    }
    {\par}

所以

\begin{pullquote}
    content for pull quote.
\end{pullquote}

 \begingroup
\begin{wrapfigure}{r}{0.35\textwidth}
        \begin{myquote}
        \end{myquote}
\end{wrapfigure}
content for pull quote.
\par
\endgroup

wrapfigure空的。

你打算

\newenvironment{pullquote}
    {\begin{wrapfigure}{r}{0.35\textwidth}
        \begin{myquote}%
    }
    {%
    \end{myquote}
    \end{wrapfigure}%
    }

因此环境的内容进入了 wrapfig 内部。但wrapfig需要调整以下段落的形状,因此不能位于诸如环境之类的组中,因此更容易使用命令

在此处输入图片描述

\documentclass[12pt,a4paper]{article}   
\usepackage{lipsum}
\usepackage{Archivo}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{sectsty}
\usepackage{xcolor}
\usepackage{tcolorbox}



%%%%%section fonts%%%%
\sectionfont{\color[HTML]{282781}}
\subsectionfont{\color[HTML]{282781}}

%%%%pullquote%%%%
\definecolor{colorquote}{HTML}{e8e9f5}
\newtcolorbox{myquote}{colback=colorquote, colframe=colorquote,arc=0pt,outer arc=0pt}

\newcommand\pullquote[1]{%
    \begin{wrapfigure}{r}{0.35\textwidth}%
        \begin{myquote}%
         #1%
        \end{myquote}%
    \end{wrapfigure}}



\DeclareUnicodeCharacter{202F}{\,}
\usepackage[colorlinks,hidelinks,urlcolor=blue,bookmarks=false,hypertexnames=true]{hyperref} 
\usepackage[notes,autocite=footnote,backend=biber,natbib=true,sorting=nyt,]{biblatex-chicago}
\ExecuteBibliographyOptions{maxcitenames=1}

\DeclareFieldFormat{citehyperref}{%
    \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
    \bibhyperref{#1}}
\savebibmacro{cite}
\renewbibmacro*{cite}{%
    \printtext[citehyperref]{%
        \restorebibmacro{cite}%
        \usebibmacro{cite}}}



\addbibresource{}
\author{Louis Vigneras}
\title{\color[RGB]{40,39,129,255}\textbf{Title}}
\begin{document}
    \maketitle
    
\lipsum[1]

\pullquote{content for pull quote.}

\lipsum*[3]
    
\end{document}

相关内容