2

I have the following code,

\documentclass{article}
\usepackage{amsmath,amssymb,amsthm}
\usepackage[most]{tcolorbox}

\begin{document}

\begin{tcolorbox}[enhanced, sharp corners, colback=white, colframe=black, drop shadow={black,opacity=1}]
\subsubsection{Méthode1.3}
Soit G un groupe, noté multiplicativement, et soit $a\in G$. Pour déterminer l'ordre de l'élément $a$, on peut:

\end{itemize}
\end{tcolorbox}

\end{document}

which generates something like,

enter image description here

However, of course it would be an overkill to type

\begin{tcolorbox}[enhanced, sharp corners, colback=white, colframe=black, drop shadow={black,opacity=1}]

every time

Therefore, I wonder if it is possible to redefine the command in some way (perhaps using \newtcolorbox), so that I do not need to type

[enhanced, sharp corners, colback=white, colframe=black, drop shadow={black,opacity=1}]

3

Yes, that is what \newtcolorbox is for.

Here is the output with tcolorbox and the MyBox enviroment defined via \newtcolorbox:

enter image description here

Code:

\documentclass{article}
\usepackage{amsmath,amssymb,amsthm}
\usepackage[most]{tcolorbox}

\pagecolor{white}

\usepackage{lipsum}

\newtcolorbox{MyBox}[1][]{%
    enhanced, 
    sharp corners,
    colback=white, 
    colframe=black, 
    drop shadow={black,opacity=1},
    #1
}%


\begin{document}

\begin{tcolorbox}[
    enhanced, 
    sharp corners, 
    colback=white, 
    colframe=black, 
    drop shadow={black,opacity=1},
]
\lipsum[1]
\end{tcolorbox}

\begin{MyBox}
\lipsum[1]
\end{MyBox}%

\end{document}
| improve this answer | |
  • Thanks. My mistake was putting those options in one of the [ ] before { } in the \newtcolorbox – Carlos - the Mongoose - Danger Dec 27 '19 at 23:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.