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?

cmhughes
  • 100,947
MaxD
  • 1,137

1 Answers1

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

Gonzalo Medina
  • 505,128
  • 1
    I suggest \usepackage[german]{isodate} and \newcommand\MyCom[1]{Datum:~\numdate\printdate{#1}} – Steven B. Segletes Feb 11 '14 at 13:57
  • @StevenB.Segletes suggestion accepted :-) – Gonzalo Medina 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. – Steven B. Segletes 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. – Gonzalo Medina 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
  • @MaxD Sorry about that. Those lines were only remnant code from some test; those lines, in fact, do nothing (at least not with the settings in my example code). I've removed those spurious lines from my answer. By the way, does the answer solve your problem or is it something else what you need? – Gonzalo Medina Feb 11 '14 at 17:12
  • @GonzaloMedina Yes, it does, thanks again! The essential thing was that I simply didn't come up with the idea of adding the argument again in title=\MyCom{#1}. Sorry, a stupid question...

    If anyone is interested, I needed this to add a function to my email chronicle (Chronicle of email correspondences) for threads in online forums where more than two people are writing.

    – MaxD Feb 11 '14 at 17:15
  • @MaxD Ah, OK. I remember your Chronicle of email correspondence :-) – Gonzalo Medina Feb 11 '14 at 17:38