-1

Consider the following code, which makes use of the cases environment in an equation:

\documentclass[a4paper]{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{amssymb}
\setlength{\parindent}{0pt}
\usepackage[T1]{fontenc}
\usepackage{stix}
\begin{document}

\begin{equation} f(x) = \begin{cases} \frac{x^{\frac{1-\alpha}{1+\alpha}- 1}}{\alpha-1} \ x \end{cases} \end{equation}

\begin{equation} g(x) = \begin{cases} \frac{x^{\frac{1-\alpha}{1+\alpha}- 1}}{\alpha-1} \ x^{\frac{x}{2}} \end{cases} \end{equation} \end{document}

This code gives the output below. Clearly, these are very ugly expressions. Ideally, I'd like to be able to adjust the vertical spaces between the two cases in both f(x) and g(x) so that they are the same. I'd also like the brace to actually fit perfectly the expression inside it for a given separation of two two cases. Neither seems to be the case here (as the vertical space between cases is inconsistent and the brace is far too large in each example). In similar questions asked on here, it is suggested that adding [... ex] after the \\ can adjust the vertical space between the two cases in the code, but this does NOT necessarily adjust the size of the brace, so we can still end up with a brace that doesn't fit. Can anyone suggest a fix?enter image description here

wrb98
  • 876
  • Have you considered that the font might be the problem. I've never seen any cases brace leave that miøuch space before, the only thing from your example that I don't regularly use is stix – daleif Sep 25 '21 at 18:22
  • I'm using the font to be consistent with a larger document which uses stix. So the font has to stay – wrb98 Sep 25 '21 at 18:34
  • Isn't there also a stix2? Or is my memory bad – daleif Sep 25 '21 at 18:35
  • There is. I think the problem is still present when other fonts are used. It just appears less exaggerated. I'm looking for a way to manually adjust the space in between cases that also adjusts the size of the brace. Just adding space between the cases often doesn't adjust the brace size, so it still looks a mess. – wrb98 Sep 25 '21 at 18:43
  • @wrb98 stix has very buggy font metrics. It's a bit better with stix2, but far from perfect. – egreg Sep 25 '21 at 20:01

2 Answers2

1

One can do TABstacks to specify the vertical baselineskip of rows. I just did it on the second equation, to match approximately the gap of the first equation.

While things will need to change if you want more than one horizontal field, the TABstack can handle tabbed fields. What it cannot do is number individual cases with their own equation number.

\documentclass[a4paper]{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{amssymb}
\setlength{\parindent}{0pt}
\usepackage[T1]{fontenc}
\usepackage{stix}
\usepackage{tabstackengine}
\TABstackMath
\begin{document}

\begin{equation} f(x) = \begin{cases} \frac{x^{\frac{1-\alpha}{1+\alpha}- 1}}{\alpha-1} \ x \end{cases} \end{equation}

\begin{equation} \setstackgap{L}{22pt} g(x) = \left{\tabbedCenterstack[l]{ \frac{x^{\frac{1-\alpha}{1+\alpha}- 1}}{\alpha-1} \ x^{\frac{x}{2}} }\right. \end{equation} \end{document}

enter image description here

  • I appreciate the input, but now the problem seems to be that I can't centre the cases in the middle of the brace... – wrb98 Sep 25 '21 at 20:04
  • Also, if I wanted to add another column to describe the individual cases, would this method still work? – wrb98 Sep 25 '21 at 20:24
  • @wrb98 I depends on how one defines "center" . If you get the horizontal math axis equidistant above and below the = sign, there will be a much larger vertical gap around the bottom term. – Steven B. Segletes Sep 25 '21 at 20:27
  • @wrb98 Yes, tabbing is supported with the use of & in each term. With [l] as given, all terms will be left aligned. The horizontal gap between tabbing fields is, for this type of stack, 0pt, but can be reset with \setstacktabbedgap{1em}, for example. – Steven B. Segletes Sep 25 '21 at 20:30
  • By centre I mean the expressions on the right of the brace being off-centre vertically. What I would really like to do is adjust the space in-between these two lines of expressions in a symmetrical way, so that there's not more space below one expression or above the other – wrb98 Sep 25 '21 at 20:30
  • 1
    @wrb98 The left brace will always be vertically centered. If one case is much taller/deeper than the other case, there will, almost by definition, be a larger empty space around one of the two cases. – Steven B. Segletes Sep 25 '21 at 20:32
  • So is there any way of shifting both lines vertically while keeping the left brace where it is (i.e. aligned with =)? Inserting \vspace{...} doesn't seem to work, but if there is a way to do this then it would fix my issue – wrb98 Sep 25 '21 at 20:43
  • 1
    +1: tabstackengine seems to be very versatile – Dr. Manuel Kuehner Sep 26 '21 at 14:32
0

I provide two options, see code. In addition, I removed a lot of your packages because they seem to be unrelated to the problem. I did not address the finer details of your question (not enough time).

\documentclass{article}
\usepackage{amsmath}
\usepackage{stix}

\begin{document}

\begin{equation} f(x) = \begin{cases} \frac{x^{\frac{1-\alpha}{1+\alpha}- 1}}{\alpha-1} \ x \end{cases} \end{equation}

\begin{equation} g(x) = \begin{cases} \frac{x^{\frac{1-\alpha}{1+\alpha}- 1}}{\alpha-1} \ x^{\frac{x}{2}} \end{cases} \end{equation}

\textbf{Option 1} % added \[2mm] % https://tex.stackexchange.com/questions/312055 \begin{equation} g(x) = \begin{cases} \frac{x^{\frac{1-\alpha}{1+\alpha}- 1}}{\alpha-1} \[2mm] x^{\frac{x}{2}} \end{cases} \end{equation}

\textbf{Option 2} % \strut % https://tex.stackexchange.com/questions/41185 \begin{equation} g(x) = \begin{cases} \frac{x^{\frac{1-\alpha}{1+\alpha}- 1}}{\alpha-1} \ x^{\strut\frac{x}{2}} \end{cases} \end{equation}

\end{document}

enter image description here

  • If you re-read my original post, you'll see that I already reference Option 1. Option 2 does not allow me to adjust manually the space between the two cases. Option 1 does allow this, but the empty vertical space at the top and bottom of the large brace will be different for f and g (adding [2mm] merely adjusts the space between cases but NOT the size of the brace!). I basically want something that looks consistent in terms of space at the top and bottom of the brace and the space in between cases. – wrb98 Sep 25 '21 at 18:04
  • @wrb98 Ok, is a -1 really appropriate? – Dr. Manuel Kuehner Sep 25 '21 at 18:34
  • If you can address the question I posed, I am happy to upvote and confirm your answer. Unfortunately, your answer (as I've just explained) doesn't currently do that. In the two examples you have given, at least one of the problems I highlighted hasn't been solved in each case. – wrb98 Sep 25 '21 at 18:36
  • @wrb98 Suit yourself. I have no interest in continuing the discussion when I spend time and effort and I get this kind of response. In addition, one can also make a clearer question that references (and shows in code) existing solutions. – Dr. Manuel Kuehner Sep 25 '21 at 18:39
  • I'm slightly perplexed by your attitude here. Your response did not answer the question posed. I simply pointed out how you could improve it. If you misunderstood the original question, you should have asked me to clarify the details. – wrb98 Sep 25 '21 at 18:50
  • @wrb98 I am perplexed by the -1 response, not your comment. – Dr. Manuel Kuehner Sep 25 '21 at 18:52