2

I added to my colorboxes the option to shift on the x axis.

Nevertheless one problem emerged : the box is doing something symmetrical and when I move it to the right, the left also goes towards the center, making the box really small. How to counter this effect ?

Here is the code (if something is still redundant, please tell me. I'm trying to know how to do MWE).

\documentclass[10pt,a4paper,twoside,openright]{book}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[left=2.5cm,right=2.5cm,top=4cm,bottom=4cm]{geometry}%réglages des marges du document selon vos préférences ou celles de votre établissemant
\setlength{\headheight}{15pt}% hauteur de l'entête

\usepackage{amsmath,amsfonts,amssymb}%extensions de l'ams pour les mathématiques
\usepackage{fancyhdr}%pour les entêtes et pieds de pages
\usepackage[most]{tcolorbox}
\usepackage[english,french]{babel}%pour un document en français

\definecolor{viol}{RGB}{134,0,175}



\tcbset{
    thmbox/.style={
        enhanced,
        breakable,
        sharp corners=all,
        fonttitle=\bfseries\normalsize,
        fontupper=\normalsize\itshape,
         top=0mm,
         bottom=0mm,
         right=0mm,
        %colback=white,
        colframe=white,
        colbacktitle=white,
        %coltitle=red,
        before={\vspace{0.1cm}}, 
        after={\vspace{0.3cm}},     
        attach boxed title to top left={xshift=-.20\linewidth, yshift= -.5 mm},
        minipage boxed title=.15\linewidth,
        left skip={0.09\linewidth},
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
        boxed title style={empty, size=minimal, bottom=1.5mm},
        overlay unbroken ={
            \draw (title.south west)--(title.south east);
            \draw ([xshift=3.5mm]frame.north west)|-%
                  (frame.south east)--(frame.north east);},
        overlay first={
            \draw (title.south west)--(title.south east); 
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);
            \draw (frame.north east)--(frame.south east);},
        overlay middle={
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);
            \draw (frame.north east)--(frame.south east);},
        overlay last={
            \draw ([xshift=3.5mm]frame.north west)|-%
                  (frame.south east)--(frame.north east);},
        },   
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEMONSTRATION
    SQ/.style={thmbox, coltitle=viol, colback=white!95!viol,  left skip={.12\linewidth},
        overlay unbroken ={
            \draw[viol][thick] (title.south west)--(title.south east);
            \draw[viol][thick] ([xshift=3.5mm]frame.north west)|-([xshift=15mm]frame.south west);
            \node[anchor=east] at (frame.south east) {$\square$};},
        overlay first={
            \draw[viol][thick] (title.south west)--(title.south east); 
            \draw[viol][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        overlay middle={
            \draw[viol][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        overlay last={
            \draw[viol][thick] ([xshift=3.5mm]frame.north west)|-([xshift=3.5mm]frame.south west);
            \node[anchor=east] at (frame.south east) {$\square$};},
    }
}

\newtcbtheorem[auto counter, number within=section]{demo}{Démonstration}{thmbox,SQ}{theo}

\begin{document}

hi !


\begin{demo}{}{}
OH!
\end{demo}

\end{document}

enter image description here

moreover I have a subsidiary question: how can I move a little bit the square (that appears in the pdf document) ? I want it to be in the box and not half outside like it is currently.

13
  • I've removed much of the useless. Can you add a screenshot of the effect you want to delete?
    – AndréC
    Apr 29, 2018 at 12:54
  • I added the picture with arrows. And you see the square on the pciture Apr 29, 2018 at 13:02
  • How do you move the box to the right? What is the code for this move?
    – AndréC
    Apr 29, 2018 at 13:10
  • attach boxed title to top left={xshift=-.20\linewidth, yshift= -.5 mm}, minipage boxed title=.15\linewidth, Apr 29, 2018 at 13:35
  • It does not move the box, it moves the title, here « Démonstration »
    – AndréC
    Apr 29, 2018 at 13:39

1 Answer 1

2

You messed up something because you use thmbox style within SQ style but they have the same option with different values, and then, again you defined a \newtcbtheorem using both of them.

I kept them separate, even if, for convenience, you can create a style with the option which are the same for both the styles and then use it for both thmbox and SQ, adding only the options which differ to each of them.

For the square symbol at the end of the text, I used \qed for asmthm and this option: after upper={\hfill$\qed$}.

I didn't change the rule setting (but it seems a bit messy to me, too) because I don't still understand which is the final look you want.

\documentclass[10pt,a4paper,twoside,openright]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{mwe}% <-- for testing purpose only, delete it

\usepackage[left=2.5cm,right=2.5cm,top=4cm,bottom=4cm]{geometry}%réglages des marges du document selon vos préférences ou celles de votre établissemant
\setlength{\headheight}{15pt}% hauteur de l'entête

\usepackage{amsmath,amsfonts,amssymb, amsthm}%amsthm added

\usepackage{fancyhdr}%pour les entêtes et pieds de pages
\usepackage[most]{tcolorbox}
\usepackage[english,french]{babel}%pour un document en français

\definecolor{viol}{RGB}{134,0,175}



\tcbset{
    thmbox/.style={
        enhanced,
        breakable,
        sharp corners=all,
        fonttitle=\bfseries\normalsize,
        fontupper=\normalsize\itshape,
        top=0mm,
        bottom=0mm,
        right=0mm,
        %colback=white,
        colframe=white,
        colbacktitle=white,
        %coltitle=red,
        before={\vspace{0.1cm}}, 
        after={\vspace{0.3cm}},     
        attach boxed title to top left={xshift=-.20\linewidth, yshift= -.5 mm},
        minipage boxed title=.15\linewidth,
        left skip={0.09\linewidth},
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
        boxed title style={empty, size=minimal, bottom=1.5mm},
        overlay unbroken ={
            \draw (title.south west)--(title.south east);
            \draw ([xshift=3.5mm]frame.north west)|-%
            (frame.south east)--(frame.north east);},
        overlay first={
            \draw (title.south west)--(title.south east); 
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);
            \draw (frame.north east)--(frame.south east);},
        overlay middle={
            \draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);
            \draw (frame.north east)--(frame.south east);},
        overlay last={
            \draw ([xshift=3.5mm]frame.north west)|-%
            (frame.south east)--(frame.north east);},
    },   
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEMONSTRATION
    SQ/.style={%thmbox,
        enhanced,
        breakable,
        sharp corners=all,
        fonttitle=\bfseries\normalsize,
        fontupper=\normalsize\itshape,
        colframe=white,
        colback=white!95!viol, 
        colbacktitle=white!95!viol,
        coltitle=viol, 
        before={\vspace{0.1cm}}, 
        after={\vspace{0.3cm}},      
        attach boxed title to top left={xshift=-.25\linewidth%, yshift= -.5 mm
        },
        minipage boxed title=.23\linewidth,
        after upper={\hfill$\qed$},
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
        %boxed title style={left=0mm, boxrule=0pt, boxsep=0pt},
        left skip={.25\linewidth},
        overlay unbroken ={
            \draw[viol][thick] (title.south west)--(title.south east);
            \draw[viol][thick] ([xshift=3.5mm]frame.north west)|-([xshift=15mm]frame.south west);},
        overlay first={
            \draw[viol][thick] (title.south west)--(title.south east); 
            \draw[viol][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        overlay middle={
            \draw[viol][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
        overlay last={
            \draw[viol][thick] ([xshift=3.5mm]frame.north west)|-([xshift=3.5mm]frame.south west);},
    }
}

\newtcbtheorem[auto counter, 
    number within=section]{demo}{Démonstration}{SQ}{theo}

\begin{document}
    hi !
    \blindtext% <-- for testing purpose only, delete it
    \begin{demo}{}{}
        OH!
    \end{demo}
    \blindtext% <-- for testing purpose only, delete it 
\end{document}

enter image description here

You must log in to answer this question.

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