I know it must be something trivial:
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage[svgnames]{xcolor}
\usepackage{framed} %http://www.latex-community.org/forum/viewtopic.php?f=44&t=5823
\colorlet{shadecolor}{gray!25}
\renewenvironment{leftbar}{%
\def\FrameCommand{\textcolor{shadecolor}{\vrule width 3pt} \hspace{10pt}}%
\MakeFramed {\advance\hsize-\width \FrameRestore}}%
{\endMakeFramed}
\declaretheorem[name=Example]{exampleOri}
\newenvironment{example}[1]{\begin{leftbar}\begin{exampleOri}[#1]}{\end{exampleOri}\end{leftbar}}
\begin{document}
\begin{example}[This is a test]
Bla
\end{example}
\end{document}
Which results in Example 1 ([). This is a test] Bla
. What is wrong here?
UPDATE: As it's not directly an answer to the question, but still useful, I wanted to post my final approach using the mdframed
key in thmtools
:
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage[svgnames]{xcolor}
\colorlet{shadecolor}{gray!25}
\declaretheorem[name=Example,
mdframed={
hidealllines=true,leftline=true,
rightmargin=0pt,innerrightmargin=0pt,
innerlinewidth=0pt,middlelinewidth=0pt,
outerlinecolor=shadecolor,outerlinewidth=3pt,
skipabove=\topskip,skipbelow=\topskip}
]{example}
\begin{document}
\begin{example}[This is a test]
Bla
\end{example}
\end{document}
example
is declared as mandatory, but you're using it with the syntax for optional arguments.\newenvironment{example}[1][]
then I get an error when I don't supply the argument. How does this work with\begin{exampleOri}[#1]
then?\newenvironment{example}[1][ ]
, a white space. Is this the right way?