3

Edit

As David rightly pointed out in the comment, I did not post what I intended. The desired output is a pull quote, that is a quote positioned on the right-hand or left-hand side of the page, wrapped by the main text, with the desired colored background declared by colorquote.

——————————————————————————————————————————

I’ve just started to learn how new environments work, so please bear with me.

I have tried the following:

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

%%%%This is the environment I’m trying to create%%%%
\definecolor{colorquote}{HTML}{e8e9f5}
\newtcolorbox{myquote}{colback=colorquote, colframe=colorquote}
\newenvironment{pullquote}[1]
    \begin{wrapfigure}{#1}{0.4\textwidth}
        \begin{myquote}
        \end{myquote}
    \end{wrapfigure}


\author{}
\title{Title}
\begin{document}
    \maketitle
    
    \section{This is some section title}
    
    \lipsum[1]
    \begin{pullquote}{R}
        Here is a quotation
    \end{pullquote}
    \lipsum[3]
    
\end{document}

Even when I try on one line:

\newenvironment{pullquote}[1]{\begin{wrapfigure}{#1}{0.4\textwidth}\begin{myquote}\end{myquote}\end{wrapfigure}}

The new environment just won’t work, and I cannot figure out why. What is wrong with it?

Also, I need the variable, but I’m not sure that I’m using it correctly. The variable would be used to either put the quoted text on the right-hand side or the left-hand side.

4
  • So the simple package tcolorbox overrides the entire LaTeX document regarding environment declaration?
    – Louis
    Mar 14, 2022 at 16:47
  • What are these specific declaration? Because I can’t seem to find them.
    – Louis
    Mar 14, 2022 at 16:50
  • I am using tcolorbox... it’s how I can create a background color for the quote..
    – Louis
    Mar 14, 2022 at 16:52
  • I’m sorry, I’m missing vocabulary here. I don’t understand what you mean. What’s the (broken) outer definition? And what is the form that appears in the document?
    – Louis
    Mar 14, 2022 at 16:54

1 Answer 1

5

The error from the posted code is

! You can't use `macro parameter character #' in vertical mode.
l.20     \begin{wrapfigure}{#
                             1}{0.4\textwidth}
? 

as

\newenvironment{pullquote}[1]
    \begin{wrapfigure}{#1}{0.4\textwidth}

is

\newenvironment{pullquote}[1]
   {\begin}
   {wrapfigure}
   {#1}{0.4\textwidth}

which defines the pullquote environment to have begin code \begin and end code wrapfigure. That is not intended but not an error. But then the remaning tokens leave #1 not inside a definition, so you get the error.

Changing things to

\newenvironment{pullquote}[1]
    {\begin{wrapfigure}{#1}{0.4\textwidth}
        \begin{myquote}}
        {\end{myquote}
    \end{wrapfigure}}

runs without error and produces

enter image description here

Which may or may not be what you want (you did not say what output you wanted)

Or

enter image description here

from

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

%%%%This is the environment I’m trying to create%%%%
\definecolor{colorquote}{HTML}{e8e9f5}
\newtcolorbox{myquote}{colback=colorquote, colframe=colorquote}
\newenvironment{pullquote}[1]
    {\begin{wrapfigure}{#1}{0.4\textwidth}
        \begin{myquote}}
        {\end{myquote}
    \end{wrapfigure}}


\author{}
\title{Title}
\begin{document}
    \maketitle
    
    \section{This is some section title}
    
    \lipsum[1]

\begin{wrapfigure}{r}{0.4\textwidth}
        \begin{myquote}
        Here is a quotation
    \end{myquote}
\end{wrapfigure}
    \lipsum*[3]
    
\end{document}

Note that you can not "hide" a tcolorbox definition inside a standard \newenvironment which is why there is the \newtcolorbox declaration form.

4
  • Ok thank you for this, I think I get it now, though it is indeed not the output I want. The output desired is a pull quote that is on the right-hand or left-hand side of the page, wrapped by the main text, with the background color.
    – Louis
    Mar 14, 2022 at 17:06
  • @Louis.vgn that's the other issue about not using tcolorbox inside a newenviornment form. Mar 14, 2022 at 17:09
  • OK thank you. Then, the newenvironment{pullquote} is simply useless, since it is unusable due to the tcolorbox used inside the very newenvironment?
    – Louis
    Mar 14, 2022 at 17:13
  • Alright, now I see what was wrong with my answer: someone changed lipsum...
    – campa
    Mar 14, 2022 at 17:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .