3

I'm looking in the tcolorbox documentation how to change the CHAPTER text to Capítulo text, but I can not find it. I tried changing something on the display, but I did not get the result I wanted.

\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
\usepackage[utf8]{inputenc}

\definecolor{titlebgdark}{RGB}{219,17,28}
\definecolor{titlebglight}{RGB}{51,41,241}

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}
{}
{10pt}
{%
    \begin{tcolorbox}[
        enhanced,
        colback=titlebgdark,
        boxrule=0.25cm,
        colframe=titlebglight,
        arc=0pt,
        outer arc=0pt,
        leftrule=0pt,
        rightrule=0pt,
        fontupper=\color{white}\sffamily\bfseries\huge,
        enlarge left by=-1in-\hoffset-\oddsidemargin, 
        enlarge right by=-\paperwidth+1in+\hoffset+\oddsidemargin+\textwidth,
        width=\paperwidth, 
        left=1in+\hoffset+\oddsidemargin, 
        right=\paperwidth-1in-\hoffset-\oddsidemargin-\textwidth,
        top=0.6cm, 
        bottom=0.6cm,
        overlay={
            \node[
            fill=titlebgdark,
            draw=titlebglight,
            line width=0.15cm,
            inner sep=0pt,
            text width=1.7cm,
            minimum height=1.7cm,
            align=center,
            font=\color{white}\sffamily\bfseries\fontsize{30}{36}\selectfont
            ] 
            (chapname)
            at ([xshift=-4cm]frame.north east)
            {\thechapter};
            \node[font=\small,anchor=south,inner sep=2pt] at (chapname.north)
            {\MakeUppercase\chaptertitlename};  
        } 
        ]
        #1
    \end{tcolorbox}%
}
\titleformat{name=\chapter sd,numberless}[display]
{\normalfont\huge\bfseries}
{}
{20pt}
{%
    \begin{tcolorbox}[
        enhanced,
        colback=titlebgdark,
        boxrule=0.25cm,
        colframe=titlebglight,
        arc=0pt,
        outer arc=0pt,
        remember as=title,
        leftrule=0pt,
        rightrule=0pt,
        fontupper=\color{white}\sffamily\bfseries\huge,
        enlarge left by=-1in-\hoffset-\oddsidemargin, 
        enlarge right by=-\paperwidth+1in+\hoffset+\oddsidemargin+\textwidth,
        width=\paperwidth, 
        left=1in+\hoffset+\oddsidemargin, 
        right=\paperwidth-1in-\hoffset-\oddsidemargin-\textwidth,
        top=0.6cm, 
        bottom=0.6cm, 
        ]
        #1
    \end{tcolorbox}%
}
\titlespacing*{\chapter}
{0pt}{0pt}{40pt}
\makeatother

%..........

\begin{document}

    \chapter{Prefácio}
    \lipsum[1]

\end{document}

enter image description here

1
  • tcolorbox does not even know what a \chapter is, so why do you expect to find a solution in the tcolorbox manual?
    – user31729
    Oct 5, 2017 at 18:08

1 Answer 1

2

Use \usepackage[portuguese]{babel} (if capítulo is portuguese ;-))

tcolorbox has no idea of \chaptername etc.

\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
\usepackage[utf8]{inputenc}

\usepackage[portuguese]{babel}

\definecolor{titlebgdark}{RGB}{219,17,28}
\definecolor{titlebglight}{RGB}{51,41,241}

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}
{}
{10pt}
{%
    \begin{tcolorbox}[
        enhanced,
        colback=titlebgdark,
        boxrule=0.25cm,
        colframe=titlebglight,
        arc=0pt,
        outer arc=0pt,
        leftrule=0pt,
        rightrule=0pt,
        fontupper=\color{white}\sffamily\bfseries\huge,
        enlarge left by=-1in-\hoffset-\oddsidemargin, 
        enlarge right by=-\paperwidth+1in+\hoffset+\oddsidemargin+\textwidth,
        width=\paperwidth, 
        left=1in+\hoffset+\oddsidemargin, 
        right=\paperwidth-1in-\hoffset-\oddsidemargin-\textwidth,
        top=0.6cm, 
        bottom=0.6cm,
        overlay={
            \node[
            fill=titlebgdark,
            draw=titlebglight,
            line width=0.15cm,
            inner sep=0pt,
            text width=1.7cm,
            minimum height=1.7cm,
            align=center,
            font=\color{white}\sffamily\bfseries\fontsize{30}{36}\selectfont
            ] 
            (chapname)
            at ([xshift=-4cm]frame.north east)
            {\thechapter};
            \node[font=\small,anchor=south,inner sep=2pt] at (chapname.north)
            {\MakeUppercase\chaptertitlename};  
        } 
        ]
        #1
    \end{tcolorbox}%
}
\titleformat{name=\chapter sd,numberless}[display]
{\normalfont\huge\bfseries}
{}
{20pt}
{%
    \begin{tcolorbox}[
        enhanced,
        colback=titlebgdark,
        boxrule=0.25cm,
        colframe=titlebglight,
        arc=0pt,
        outer arc=0pt,
        remember as=title,
        leftrule=0pt,
        rightrule=0pt,
        fontupper=\color{white}\sffamily\bfseries\huge,
        enlarge left by=-1in-\hoffset-\oddsidemargin, 
        enlarge right by=-\paperwidth+1in+\hoffset+\oddsidemargin+\textwidth,
        width=\paperwidth, 
        left=1in+\hoffset+\oddsidemargin, 
        right=\paperwidth-1in-\hoffset-\oddsidemargin-\textwidth,
        top=0.6cm, 
        bottom=0.6cm, 
        ]
        #1
    \end{tcolorbox}%
}
\titlespacing*{\chapter}
{0pt}{0pt}{40pt}
\makeatother

\begin{document}

    \chapter{Prefácio}
    \lipsum[1]

\end{document}

enter image description here

1
  • Thank you my friend, but here is a Brazilian. Then in this case, Portuguese. ;)
    – LCarvalho
    Oct 5, 2017 at 18:17

You must log in to answer this question.

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