0

I currently have this command:

\NewDocumentCommand{\deq}{omo}{%
  \begin{tcolorbox}[
    colback = blizzardblue!30!white,
    colframe = white,
  ]
  \setlength{\abovedisplayskip}{0pt}
  \begin{flalign}
    \IfValueT{#1}{\text{\Emph{#1}}} && #2 &&
  \end{flalign}
  \IfValueT{#3}{\emph{#3}}
  \end{tcolorbox}\noindent
}

and this code:

\deq[Equation's title]{pV = nRT}

that produces

enter image description here

I'm looking for a way to improve that command to be able to write more than 1 equation. For example, with this code:

\documentclass{book}
\usepackage[italicdiff]{physics}
\usepackage[scr = rsfso]{mathalfa}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{tcolorbox}
\tcbuselibrary{skins, breakable, hooks, theorems}
\usepackage{xcolor}
\definecolor{blizzardblue}{rgb}{0.4, 0.6, 0.8}

\begin{document} \begin{tcolorbox}[ colback = blizzardblue!30!white, colframe = white] \begin{gather} \begin{align} \qty(\pdv{T}{V})_S &= -\qty(\pdv{p}{S})_V \ \qty(\pdv{T}{p})_S &= +\qty(\pdv{V}{S})_p \ \qty(\pdv{S}{V})_T &= +\qty(\pdv{p}{T})_V \ \qty(\pdv{S}{p})_T &= -\qty(\pdv{V}{T})_p \end{align} \end{gather} \end{tcolorbox} \end{document}

I'd like to be able to produce this (edited figure):

enter image description here

for any number of equations. Of course, I'm able to use tcolorbox environment and gather / equation environment to write something like that but I can't place -- in the right place -- the equation title. The "right place" is maximally separated (and automatically) from the equations but also centered vertically to all the equations (and of the tcolorbox environment).

The ideal answer to this question would be a new command for N equations with an optional title (which must be centered vertically and maximally separated from the equations). Thanks for reading and helping!

Peluche
  • 613
  • Doesn't the manual of tcolorbox provide an example how to incorporate the title inside a box without defining a new command? – alchemist Feb 09 '23 at 20:13
  • Yes, there is and I know how but it doesn't fit for me that kind of title. I've rewrote the question. Sorry for my bad writing – Peluche Feb 10 '23 at 01:25
  • 1
    Your code don't compile. You have forgot to add the tcolorbox package and the package (or the definition) which define the color "blizzardblue". – quark67 Feb 10 '23 at 01:48
  • Can you specify the expected behavior of the equations when the "Equation title" is very long? In your edited figure, equations are horizontally centered, but when the Equation title is long, would you a narrow gap between the Equation title and the equations, and a large gap between the equations and the labels? – quark67 Feb 10 '23 at 02:15
  • When the "Equation's title" is too long, the space between the equation and it's number (\theequation) gets shorter (that's what happens and what I would expect). But, the titles I'm using are shorts, so there wouldn't be a case of "title too long" – Peluche Feb 10 '23 at 02:20

1 Answers1

1

Here is a solution. I have replaced the call to the package physics to the call to the package derivative because physics is not recommanded (see Alternatives to the physics package by the way, there is a new package called physics2 which replace some functionalitys of physics package, see https://www.ctan.org/pkg/physics2 and the document http://mirrors.ctan.org/macros/latex/contrib/physics2/doc/physics2-legacy.pdf for switching from physics to physics2). It isn't need to load xcolor because tcolorbox load it.

\documentclass{article}

\usepackage{derivative}

\usepackage{mathtools} \usepackage{amssymb}

\usepackage{tcolorbox}

\definecolor{blizzardblue}{rgb}{0.4, 0.6, 0.8}

\newcommand{\mybox}[2][]{% \tcbsidebyside[sidebyside adapt=left, sidebyside gap=5mm,colback = blizzardblue!30!white,colframe = blizzardblue!30!white ]{% #1 }{% \begin{gather} \begin{align} #2
\end{align} \end{gather} } }

\begin{document}

\mybox[Equation title]{% \pdv{T}{V}_S &= -\pdv{p}{S}_V \ \pdv{T}{p}_S &= +\pdv{V}{S}_p \ \pdv{S}{V}_T &= +\pdv{p}{T}_V \ \pdv{S}{p}_T &= -\pdv{V}{T}_p }

\end{document}

Result:

enter image description here

quark67
  • 4,166
  • any chance that there's something missing or anything I may not have? It is not compiling Undefined control sequence. \\mybox [#1]#2->\tcbsidebyside. I only have what you wrote and it's not compiling – Peluche Feb 10 '23 at 03:59
  • I using Tex Live 2022 and pdflatex for the compilation. \tcbsidebyside is from 2015-11-20 version of tcolorbox (page 138, section 6.2 of the documentation at http://mirrors.ctan.org/macros/latex/contrib/tcolorbox/tcolorbox.pdf). – quark67 Feb 10 '23 at 04:11
  • According this post (MikTex) I have all my tex packages updated :(. Any idea where can I read how to fix this and use your answer? – Peluche Feb 10 '23 at 04:39
  • Can you add \listfiles in your preamble (e.g. right after \documentclass{article})? Then see your .log file to find the version of tcolorbox used (in my case, I read: tcolorbox.sty 2022/06/24 version 5.1.1 text color boxes). – quark67 Feb 10 '23 at 04:48
  • Yep, I have an older version: 2022/01/07 version 5.0.2, even though miktex says that there's not any update available – Peluche Feb 10 '23 at 04:50
  • Does the code on page 138 of http://mirrors.ctan.org/macros/latex/contrib/tcolorbox/tcolorbox.pdf works? Be careful when you copy/paste the code from the pdf viewer, as some line can be pasted after a % sign (for me, the line \begin{tikzpicture} and }{%). Don't forget to load the skins library (\tcbuselibrary{skins}) and the lipsum and tikzpackage). – quark67 Feb 10 '23 at 05:05
  • No, it doesn't work. The \tcbsidebyside causes the error I believe – Peluche Feb 10 '23 at 05:08
  • 1
    Can you consider installing Tex Live or using Overleaf instead of MikTeX? Or create a new question (perhaps MikTeX has broken the installation of tcolorbox. It's also strange that you can't install the latest version of tcolorbox). Try also to compile the file tcolorbox-example.tex from https://ctan.org/tex-archive/macros/latex/contrib/tcolorbox to see if there are another things broken in tcolorbox installed by MikTeX. – quark67 Feb 10 '23 at 05:28