0

(I´m sorry my poor English) How could I adjust a tcolorbox, with minimal side space, so that the paragraph and the equation within it are in the same alignment as the other normal paragraphs?

I was trying to use the example below, but would like to have a general macro in the block definition for the theorem, or other blocks.

(new edit: I would like have a paragraph (and equations) inside block the same size margins outside block, using \usepackage[margin=1.5cm ]{geometry}. The name Theorem aligned like \noindent paragraph. I don´t have problem with the tcolorbox outside margins, and in deed this is my wish: have the tcolorbox outside margins, 1 or 2 mm, using the definition \newtcolorbox below)

Below a MWE,

Thanks for the help.

Big tcolorbox going out of the page, center on full paper width

enter image description here

\documentclass[12pt, a4paper]{report}
\usepackage{mathpazo, amsmath,amsfonts,amscd,bezier, amssymb, ifthen,amsthm}
\usepackage[x11names, usenames,svgnames,dvipsnames, table]{xcolor}
\colorlet{lightcyan}{cyan!40!white}
\usepackage{babel}
\usepackage{blindtext}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage{changepage}
\RequirePackage[babel=true]{microtype}
\usepackage{enumerate}
\usepackage[shortlabels]{enumitem}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{tasks}
\usepackage{graphicx}
\usepackage{float}
\usepackage[margin=1.5cm ]{geometry}
\usepackage{pgfplots}
\usepackage{mathtools}
\usepackage[most]{tcolorbox}

\usepackage[makeroom]{cancel}
\usepackage[colorlinks=true]{hyperref}
\hypersetup{allcolors=magenta}

\everymath{\displaystyle}

\newtcolorbox[auto counter,number within=chapter, number format=\arabic]{theo}[1][]{
    title={Theorem~\thetcbcounter},
    colframe=violet,
    colback=violet!12!white,
    fontupper=\itshape,
    boxed title style={colback=violet},
    overlay unbroken and first={
        \node[below right,font=\small,color=violet,text width=\linewidth]
        at (title.north east) {#1};
    }
}

\usepackage{lipsum}

\RequirePackage[onehalfspacing]{setspace}
\begin{document}
    \pagestyle{myheadings} \thispagestyle{empty}
    
\lipsum[11]

\begin{equation}
    f(x)= x^3
\end{equation}

\begin{theo}
\lipsum[11] 
\begin{equation}
    f(x)= x^3
\end{equation}

\end{theo}  

\begin{adjustwidth}{-5mm}{-5mm}
\begin{theo}
    \lipsum[11] 
    \begin{equation}
        f(x)= x^3
    \end{equation}
\end{theo}
\end{adjustwidth}
    
\end{document}

2 Answers 2

0

Delete this two lines:

\begin{adjustwidth}{-5mm}{-5mm}

\end{adjustwidth}
1
  • I'm sorry, I want to use a block outside the paragraph itself, so that the text inside it is aligned with the rest of the text outside the block.
    – Moura
    Commented Feb 26, 2023 at 18:51
0

To answer to @Moura comment we can consider this code (that conctact EACH paragraph containing numbered equations outside the colored boxes and DONT enlarge colored boxes with numbered equations):

\documentclass[12pt, a4paper]{report}
\usepackage{mathpazo, amsmath,amsfonts,amscd,bezier, amssymb, ifthen,amsthm}
\usepackage[x11names, usenames,svgnames,dvipsnames, table]{xcolor}
\colorlet{lightcyan}{cyan!40!white}
\usepackage{babel}
\usepackage{blindtext}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage{changepage}
\RequirePackage[babel=true]{microtype}
\usepackage{enumerate}
\usepackage[shortlabels]{enumitem}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{tasks}
\usepackage{graphicx}
\usepackage{float}
\usepackage[margin=1.5cm ]{geometry}
\usepackage{pgfplots}
\usepackage{mathtools}
\usepackage[most]{tcolorbox}

\usepackage[makeroom]{cancel}
\usepackage[colorlinks=true]{hyperref}
\hypersetup{allcolors=magenta}

\everymath{\displaystyle}

\newtcolorbox[auto counter,number within=chapter, number format=\arabic]{theo}[1][]{
    title={Theorem~\thetcbcounter},
    colframe=violet,
    colback=violet!12!white,
    fontupper=\itshape,
    boxed title style={colback=violet},
    overlay unbroken and first={
        \node[below right,font=\small,color=violet,text width=\linewidth]
        at (title.north east) {#1};
    }
}

\usepackage{lipsum}

\RequirePackage[onehalfspacing]{setspace}
\begin{document}
    \pagestyle{myheadings} \thispagestyle{empty}
    
    \lipsum[11]
    \begin{adjustwidth}{5mm}{5mm}   %<--- added 
        \begin{equation}
        f(x)= x^3
        \end{equation}
    \end{adjustwidth}               %<--- added 
    \begin{theo}
        \lipsum[11] 
        \begin{equation}
            f(x)= x^3
        \end{equation}
        
    \end{theo}  
    
%   \begin{adjustwidth}{-5mm}{-5mm} <--- removed
        \begin{theo}
            \lipsum[11] 
            \begin{equation}
                f(x)= x^3
            \end{equation}
        \end{theo}
%   \end{adjustwidth}               <--- removed
    
\end{document}

The output is:

enter image description here

1
  • Thank you, I'm sorry, my English is so bad. I would like have a paragraph (and equations) inside block the same size margins outside block. The name Theorem aligned like \noindent paragraph. I don´t have problem with the tcolorbox outside margins, and in deed this is my wish: have the tcolorbox outside margins, 1 or 2 mm, using \newtcolorbox
    – Moura
    Commented Feb 28, 2023 at 11:49

You must log in to answer this question.

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