2

I want to label each case in cases so I used subnumcases environment. However, it seems like what is centered is the first letter, not the entire chunk.

I made a MWE with the packages I need for my work, and by toggling off the packages one by one, I found that mathtools cellspace empheq are causing the ugly alignment. (for empheq, maybe I can go without it.)

This is the MWE script:

\documentclass[12pt]{article}
\usepackage[top=2.5cm, left=2.5cm, right=2.5cm, bottom=3cm]{geometry}
\usepackage{amsmath,amsfonts}
\usepackage{showframe}
\usepackage{cases}
% when any of the packagages below(mathtools, cellspace, empheq) is used, it gives the ugly output like in the screenshot. 
\usepackage{mathtools}
%\usepackage{cellspace}
%\usepackage{empheq}

\begin{document}
    %%%%%%%%%%%%%%%%%%%%%%% 
    When using {\bfseries subnumcases environment} with mathtools, cellspace, or empheq, it seemas like its starting point is centered
    \begin{subnumcases}{f(x)=}
        x & $0<x<1$ \\
        1000000000000000000000000000x  & $1\leq x$
    \end{subnumcases}
    
    But {\bfseries cases environment} is okay and and I want the alignment of subnumcases also to be like this.
    \begin{equation}
        f(x)=
        \begin{cases}
            x & 0<x<1 \\
            1000000000000000000000000000x  & 1\leq x
        \end{cases}
    \end{equation}
    
    %%%%%%%%%%%%%%%%%%%%%%% 
\end{document}

And this is my ugly output with mathtools: ugly alignment of subnumcases

How can I have center-aligned subnumcases environment while using mathtools cellspace empheq packages?

Thanks!

P.S. if you have any other way to have sub-numbers for cases, it's also welcome. I tried subequations, but found difficulty to put it in case for like "f(x) = { " part at the left of the subequations chunk.

+ I'm using texstudio and I'm adding the screenshot of the compiled output in texstudio.enter image description here

6
  • Exactly where are you compiling this? If I compile your code both are aligned just nicely. Also note your comment ugly output with mathtools has nothing to do with mathtools as you get the same output with it.
    – daleif
    Jan 19 at 13:24
  • I'm unable to reproduce the problem with your code.
    – egreg
    Jan 19 at 14:14
  • @daleif I'm working with texstudio and when I activate \usepackage{mathtools}, it gives me the ugly output. mathtools, and also cellspace and empheq is not used in the MWE but I need them for my thesis file so I added it. It makes me crying it doesn't even reproduce the same problem there.... I really don't know what the problem is :(.....
    – Sam Bach
    Jan 23 at 9:21
  • @egreg I just tried the code in Overleaf and what??! it works fine...!!!! now it makes me even crazier. maybe it's texstudio's problem? how could such problem happen...
    – Sam Bach
    Jan 23 at 9:28
  • 1
    Add \listfiles before \documentclass, that adds a list of files and their versions to the log. Update your question with that entire log (the log specifically from your compilation of the posted example).
    – daleif
    Jan 23 at 10:35

1 Answer 1

0

I can't reproduce your issue, but you don't need cases if you load empheq.

\documentclass[12pt]{article}
\usepackage[
  top=2.5cm,
  left=2.5cm,
  right=2.5cm,
  bottom=3cm
]{geometry}
\usepackage{amsmath,amsfonts}

\usepackage{cellspace}
\usepackage{mathtools}
\usepackage{empheq}

% for debugging
\usepackage{showframe}

\newcommand{\topstrut}{\smash[b]{\vphantom{\big|}}}
\newcommand{\botstrut}{\smash[t]{\vphantom{\big|}}}

\begin{document}

When using the \textbf{subnumcases environment} with mathtools, cellspace, or empheq, 
it seems like its starting point is centered
\begin{subequations}
\begin{empheq}[left={f(x)=\empheqlbrace}]{alignat=2}
  & x                              &\quad& 0<x<1 \topstrut \\
  & 1000000000000000000000000000x  &\quad& 1\leq x \botstrut
\end{empheq}
\end{subequations}
But the \textbf{cases environment} is okay and and I want the alignment of subnumcases 
also to be like this.
\begin{equation}
  f(x)=
  \begin{cases}
    x & 0<x<1 \\
    1000000000000000000000000000x  & 1\leq x
  \end{cases}
\end{equation}
    
\end{document}

I added \topstrut and \botstrut just to make the two cases the same.

enter image description here

You must log in to answer this question.

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