1

I have the following working code:

\documentclass[11pt, oneside]{book}

\renewcommand\sfdefault{cmss}
\renewcommand{\familydefault}{\sfdefault}

\usepackage[top = 2.54cm, bottom = 2.54cm, left = 1.5cm, right = 1.5cm]{geometry}

\usepackage{physics}
\usepackage[italic = true]{derivative}
\usepackage[scr = rsfso]{mathalfa} 
\usepackage{mathtools}
\usepackage{amssymb}

\usepackage{chngcntr}
  \numberwithin{equation}{chapter}

\usepackage{tcolorbox}
    \tcbuselibrary{skins, xparse, breakable, hooks, theorems}
\definecolor{blizzardblue}{rgb}{0.4, 0.6, 0.8}

\NewDocumentCommand{\bcases}{som}{%
    \IfBooleanTF{#1}{
        \tcbsidebyside[righthand ratio = 0.6,
        colback = blizzardblue!30!white, 
        colframe = blizzardblue!30!white,
        ]{{\bfseries #2}}{%
        \begin{gather*}
            \begin{cases}
                #3  
            \end{cases}
        \end{gather*}
        }\noindent
    }{
        \tcbsidebyside[righthand ratio = 0.6,
        colback = blizzardblue!30!white, 
        colframe = blizzardblue!30!white
        ]{{\bfseries #2}}{%
        \begin{gather}
            \begin{cases}
                #3      
            \end{cases}
        \end{gather}
        }\noindent
}}


   \begin{document}
        \bcases[Sphericals to Cartesians]{
        x & = r~\sin{\theta} \cos{\phi} \\
        y & = r~\sin{\theta} \cos{\phi} \\
        z & = r~\cos{\theta}
    }
    \end{document}

that produces

enter image description here

What I'm trying to fix is to minimize the horizontal space that Sphericals to Cartesians uses and to maximize (and to center) the space for the cases environment. Right know, this last environment is too at the right of the page, I need it more centered.

I already try without sucess changing the righthand ratio, lefthand ratio and adding sidebyside align=right in the options of \tcbsidebyside (this one gives error, idk why).

The answer to this question would be a code to replicate this (the figure is edited):

enter image description here

Thanks for read this and keep helping!

3
  • 1
    Your code don't give the 1st output. Your code outputs the text in serif, not sans serif font as displayed. Perhaps have you forgot \renewcommand{\familydefault}{\sfdefault} in preamble? Also, I don't obtain so much space between "Cartesian" and the brace. With the adding of the \renewcommand above, the blank has approximatively the length of the chars "Sphericals to C". Perhaps have you changed the margin size with the package geometry? And the equation label obtained is (1), not (1.20). Please correct your code in the question, so it correspond to the first image displayed. Thanks.
    – quark67
    Feb 24, 2023 at 0:44
  • Done! Now you get the exact image displayed with the code given (sorry for the missing code). About why you get the space you're saying between "Cartesian" and the brace, that's something I don't know. Using only the code I wrote, I get the first image displayed
    – Peluche
    Feb 24, 2023 at 1:04
  • As you have changed the margins, the blank between "Cartesians" and the brace is a lot bigger yet, as displayed in the first image. It's OK.
    – quark67
    Feb 24, 2023 at 1:13

1 Answer 1

2

As you probably don't want flush left aligned equations through the entire document, I don't use the global document class option fleqn here.

So I use the package nccmath which provide the environment fleqn. Notice that this package slightly reduce the vertical space before and after the displayed equation.

In this code, I use use the environment fleqn, and in it, I use the usual environment gather (and it's starred version).

Minor typographic adjustements: I have replaced x & = r~\sin (and so on) in your code by x = r\sin (and so on), so the spaces between elements are better adjusted (the space before and after the = is the same, and the space between r and "sin" is as between "sin" and "cos").

Note that \sin and so on don't take argument, so I have replaced \sin{\theta} by \sin\theta.

I have also corrected the conversion formula, but it is not important.

Finally, I have removed unused packages (physics, derivative, mathalfa, amssymb). About the physics package, it is probably better replaced by the new physics2 (doc: http://mirrors.ctan.org/macros/latex/contrib/physics2/doc/physics2.pdf) and some other packages (see the section 1.1 of http://mirrors.ctan.org/macros/latex/contrib/physics2/doc/physics2-legacy.pdf about problems with the physics package).

Code:

\documentclass[11pt, oneside]{book}

\renewcommand\sfdefault{cmss}
\renewcommand{\familydefault}{\sfdefault}

\usepackage[top = 2.54cm, bottom = 2.54cm, left = 1.5cm, right = 1.5cm]{geometry}
 
\usepackage{mathtools}
\usepackage{nccmath} % >>> provide the fleqn environment

\usepackage{chngcntr}
  \numberwithin{equation}{chapter}

\usepackage{tcolorbox}
    \tcbuselibrary{skins, xparse, breakable, hooks, theorems}
\definecolor{blizzardblue}{rgb}{0.4, 0.6, 0.8}

\NewDocumentCommand{\bcases}{som}{%
    \IfBooleanTF{#1}{
        \tcbsidebyside[righthand ratio = 0.75,
        colback = blizzardblue!30!white, 
        colframe = blizzardblue!30!white,
        ]{{\bfseries #2}}{%
        \begin{fleqn}
            \begin{gather*}
                \begin{cases}
                    #3  
                \end{cases}
            \end{gather*}
        \end{fleqn}
        }\noindent
    }{
        \tcbsidebyside[lefthand ratio = 0.25,
        colback = blizzardblue!30!white, 
        colframe = blizzardblue!30!white
        ]{{\bfseries #2}}{%
        \begin{fleqn}
            \begin{gather}
                \begin{cases}
                    #3      
                \end{cases}
            \end{gather}
        \end{fleqn}
        }\noindent
}}


   \begin{document}
        \bcases[Sphericals to Cartesians]{
        x = r\sin\theta \cos\phi \\
        y = r\sin\theta \sin\phi \\
        z = r\cos\theta
    }
    \end{document}

Result:

enter image description here

Comparison with the OP code (I have colored differently the two sides, by adding the line bicolor,colbacklower = red!30!white, between colback = and colframe = ):

enter image description here

You must log in to answer this question.

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