2

I have the following LaTeX snippet:

\begin{figure}[h]

  \centering
  \[\scalebox{2}{\color{blue}$some formula$}\]
  \caption{a caption \label{fig:the-label}}

\end{figure}

I'm trying to create a new float environment that does most of the formating for me, such that I can simply type

\begin{bigblue}
  $some formula$
  \caption{a caption \label{fig:the-label}}
\end{bigblue}

I've tried the environ and the float package, but I was not able to do this. Is it possible?

Solution Thanks to Herbert, I've come up with the following solution:

\documentclass{article}
\usepackage{mathtools}
\usepackage{xcolor}
\usepackage{caption}
\usepackage{floatrow}
\DeclareNewFloatType{bigblue}{placement=!htb,fileext=bb,name=Figure}
\DeclareFloatFont{blue}{\color{blue}}
\DeclareFloatFont{Huge}{\Huge}
\floatsetup[bigblue]{style=plain,framefit=yes,font={Huge,blue},valign=c}
\usepackage{blindtext}

\begin{document}
In \ref{myformula} we see

\blindtext

\begin{bigblue}
  \[ E = mc^2 \] 
  \caption{foo\label{myformula}}
\end{bigblue} 

\blindtext

\end{document}
1
  • Apparently you want to have formulas floating around?
    – user31729
    Feb 18, 2016 at 16:01

2 Answers 2

1
\documentclass{article}
\usepackage{mathtools}
\usepackage{xcolor}
\usepackage{caption}
\usepackage{floatrow}
\DeclareNewFloatType{bigblue}{placement=!htb,fileext=bb,name=BlueEqn}
\DeclareColorBox{bblue}{\colorbox{blue!30}}
\floatsetup[bigblue]{style=plain,framestyle=colorbox,framearound=row,
    colorframeset=bblue,framefit=yes,valign=c}
\usepackage{blindtext}

\begin{document}
In \ref{myformula} or in \eqref{myotherformula} we see

\blindtext

\begin{bigblue}
 \[ E = mc^2 \] 
 \caption{foo\label{myformula}}
\end{bigblue} 

\blindtext

\begin{bigblue}
\begin{equation} E^2 = p^2c^2 + (mc^2)^2 \label{myotherformula} \end{equation}
\caption{bar\label{Some}}
\end{bigblue} 

\end{document}

enter image description here

0
1

Here's a floating tcolorbox version, however, not fully satisfactory due to the \tcblower statement being necessary to put the title below the upper box (being an ams equation box).

\documentclass{article}


\usepackage[most]{tcolorbox}
\newtcolorbox{bigblue}[2][]{
  ams equation upper,
  sharp corners, 
  enhanced jigsaw,
  boxrule=0pt,
  float=b,
  colback=white,
  colupper={blue},
  coltitle={black},
  lower separated=false,
  detach title,
  before lower={\tcbtitle\par},
  title={\centering 

    \bfseries Equation \theequation: #2

  },
  #1
}

%\AtEndEnvironment{bigblue}{\tcblower}

\usepackage{blindtext}

\begin{document}

In \eqref{myformula} or in \eqref{myotherformula} we see

\blindtext[2]

\begin{bigblue}{Foo}
  E = mc^2 \label{myformula}
  \tcblower
\end{bigblue} 

\blindtext[5]

\begin{bigblue}{Foobar}
  E^2 = p^2c^2 + (mc^2)^2 \label{myotherformula}
\tcblower
Some addition
\end{bigblue} 



\end{document}
3
  • Thank you for the suggestion, but unfortunately I need to use the \caption command, it's code generated from Org-mode.
    – brab
    Feb 18, 2016 at 18:07
  • @brab: And why did you not write this information into the question? Now my solution is useless, of course
    – user31729
    Feb 18, 2016 at 18:24
  • I thought I had given an example of what it would look like. Sorry for the confusion.
    – brab
    Feb 19, 2016 at 7:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .