7

I want to do something like this:

\documentclass{article}    
\usepackage[ngerman]{isodate} %for printing the date
\usepackage[dvipsnames]{xcolor} %for color names
\usepackage{tcolorbox}
\usepackage{lipsum}

\newcommand{\MyArgument}{Datum: \printdate{#1}}

\newtcolorbox{MyBox1}[1]{colback=red!5!white, colframe=red!75!black, title=\MyArgument }

%some more "\newtcolorbox{...}" with different colors, but all with title=\MyArgument

\begin{document}

 \begin{MyBox}{2014-02-11}
  \lipsum
 \end{MyBox}

\end{document}

The output should be a box with the title "Datum: 11. Februar 2014" (German date format)

The purpose is that I want to be able to change the title of all boxes at the same time. How can I do that?

2
  • Providing a compilable example that begins with \documentclass is extremely helpful to those who wish to help you. Feb 11 '14 at 13:41
  • Thanks, I added it now. A also changed the date format to German because this led to some confusion.
    – MaxD
    Feb 11 '14 at 17:27
9

Not sure if this is what you want:

\documentclass[dvipsnames]{article}
\usepackage{tcolorbox}
\usepackage[english]{isodate} %for printig the date
\usepackage{lipsum}

\newcommand\MyCom[1]{Datum:~\numdate{#1}}

\newtcolorbox{MyBoxi}[1]{
  colback=red!5!white,
  colframe=red!75!black,
  title=\MyCom{#1}
}
\newtcolorbox{MyBoxii}[1]{
  colback=cyan!5!white,
  colframe=cyan!75!black,
  title=\MyCom{#1}
}

\begin{document}

 \begin{MyBoxi}{2014-02-11}
  \lipsum[4]
 \end{MyBoxi}

 \begin{MyBoxii}{2014-02-11}
  \lipsum[4]
 \end{MyBoxii}

\end{document}

enter image description here

8
  • 1
    I suggest \usepackage[german]{isodate} and \newcommand\MyCom[1]{Datum:~\numdate\printdate{#1}} Feb 11 '14 at 13:57
  • @StevenB.Segletes suggestion accepted :-) Feb 11 '14 at 14:30
  • 1
    The \numdate gives the date as 11.02.2014 instead of 11. Februar 2014, as requested by the OP. Feb 11 '14 at 14:36
  • 1
    @StevenB.Segletes I am not sure whether the OP is also asking for a way to change the date format. I'll use your suggestion for \numdate as well. Thanks. Feb 11 '14 at 15:17
  • @GonzaloMedina Sorry for the confusing formulation! This seems to be the essential part I was asking for: \makeatletter \def\iso@isodash{mmmmm} \makeatother Can you explain what it does?
    – MaxD
    Feb 11 '14 at 17:01

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.