Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Providing a compilable example that begins with \documentclass is extremely helpful to those who wish to help you. –  Steven B. Segletes Feb 11 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 at 17:27

1 Answer 1

up vote 10 down vote accepted

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

share|improve this answer
1  
I suggest \usepackage[german]{isodate} and \newcommand\MyCom[1]{Datum:~\numdate\printdate{#1}} –  Steven B. Segletes Feb 11 at 13:57
    
@StevenB.Segletes suggestion accepted :-) –  Gonzalo Medina Feb 11 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 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 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 at 17:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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