Math & ScienceNumbering subequations within cases-like format

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
veks
Posts: 2
Joined: Wed Jun 06, 2012 12:04 pm

Numbering subequations within cases-like format

Post by veks »

Hello!
This is my first post here, I hope I will be clear and follow the rules.

This is an example of the type of equations I would like to put in my document:

Code: Select all

\documentclass{article}
\begin{document}
\begin{equation}
\begin{array}{cl}
\displaystyle{\min_{x}} & f(x) \\ 
\textrm{subject to} & 
\left\{ 
\begin{array}{l}
A x \le b \\ C x = d 
\end{array} 
\right.
\end{array}
\end{equation}
\end{document}
My problem is that I would like to label all subequations, that is, I would like to have (1a) next to f(x), (1b) next to Ax<=b and (1c) next to Cx=d.

If I use align instead of equation+array I can get two labels, one for the cost and one for the constraints, but this is enough for my purpose.
I also played with subnumcases from the cases package, but I don't know how to make it work if the cases are a part of larger equation.

Any help will be much appreciated. Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10359
Joined: Mon Mar 10, 2008 9:44 pm

Numbering subequations within cases-like format

Post by Stefan Kottwitz »

Hi veks,

welcome to the board!

You could use a subequations environment. For example:

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{subequations}
  \begin{equation}
    \displaystyle{\min_{x}}  f(x) \\
  \end{equation}
  \begin{equation}
    \textrm{subject to} 
    \left\{
    \begin{array}{l}
      A x \le b \\ C x = d
    \end{array}
    \right.
  \end{equation}
\end{subequations}
\end{document}
Stefan
LaTeX.org admin
veks
Posts: 2
Joined: Wed Jun 06, 2012 12:04 pm

Re: Numbering subequations within cases-like format

Post by veks »

Thanks very much for your reply Stefan. Unfortunately, this does not solve my problem.

The code you sent adds (1a) next to the first line (min f(x)) and (1b) next to the second part (list of constraints). What I would like to have is a number next to EACH constraint that is inside the "cases-like" statement, i.e. (1b) next to "Ax<=b" and (1c) next to Cx=d. In other words, I have an array of equations within another array of equations (in order to get the formatting I need), and I would like to number the equations of the inner array.

Thanks!
Post Reply