12

I would like to write in LaTeX two equations:

equation1

and

enter image description here

I do not know how to do that...Particularly, how to write stuff underneath the max function. And also how to have this line over Wi or Wj.

PS: I do not ask for the whole equations, I am asking for the part that I do not know how to write in LaTeX :))

3 Answers 3

13

In the case of \max, the text below automatically. For other operators (like \int) or for inline formulas, you can use \limits. Longer text has to be in curly brackets:

\max\limits_{n_j \in succ(n_i)}

To get a line over your text, you can use \overline:

\overline{w_i}

Your formulas would be:

rank_u(n_i) = \overline{w_i} + \max\limits_{n_j \in succ(n_i)} (\overline{c_{ij}} + rank_u(n_j))
rank_d(n_i) = \max\limits_{n_j \in pred(n_i)} \{rank_d(n_j) + \overline{w_j} + \overline{c_{i,j}}\}

If you want to typeset rank and succ as an operator like max, you can either use \text{rank} from amsmath, or declare rank as a math operator (in your preamble):

\DeclareMathOperator{\rank}{rank}
\DeclareMathOperator{\successor}{succ}

Please note that I chose \successor over \succ, as this is already used for a math symbol.

4
  • 1
    If the material material is typeset in displaymath mode, it is not necessary to use the \limits directive to inform LaTeX that the argument of the \max command should be typeset below the string "max".
    – Mico
    Commented Feb 12, 2014 at 11:01
  • You're right, in the case of \max in displaymath it is not necessary. I've thought of other operators like \intwhere one would need \limits. I've corrected this. Commented Feb 12, 2014 at 11:13
  • Thanks for this solution: I chose this one for my document :)
    – MrJay42
    Commented Feb 12, 2014 at 12:43
  • @Mrjay42 You're welcome :-) Commented Feb 12, 2014 at 13:29
16

To have LaTeX place some material below below the string "max", simply use the macro \max_{...}: If you're in displaymath mode (which you will be if you're in an environment such as equation), this will result in the argument of the \max command being placed below (rather than in a subscript position) the string "max".

Separately, I would recommend that you typeset the strings "rank", "pred", and "succ" in upright-roman characters since they denote math "operators". One way to do this is to load the amsmath package and use its \DeclareMathOperator instruction to define the corresponding macros \rank, \pred, and \succ. Aside: Because the macro \succ already exists -- and creates a math symbol that looks like a curvy > sign -- it has to be undefined first before it can be redefined as a math operator. Obviously, if you need to use the original meaning of \succ elsewhere in your document, you should not redefine it to act as a math operator; instead, devise a new macro name, e.g., \succeeds.

Furthermore, I would use the \bar instruction to create lines above the "c" and "w" characters. Doing so creates horizontal lines that aren't quite as "heavy" as those produced by \overline.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for \DeclareOperator macro and align environment
\DeclareMathOperator{\rank}{rank}
\DeclareMathOperator{\pred}{pred}
\let\succ\relax % undefine \succ first
\DeclareMathOperator{\succ}{succ} % now redefine it as an "operator"
\begin{document}
\begin{align*}
\rank_u(n_i)&=\bar{w}_i + \max_{n_j\in\succ(n_i)}
  \bigl(\bar{c}_{i,j}+\rank_u(n_j)\bigr)\\
\rank_d(n_i)&=\bar{w}_i + \max_{n_j\in\pred(n_i)}
  \bigl\{ \rank_d(n_j)+\bar{w}_j+\bar{c}_{j,i}\bigr\}
\end{align*}
\end{document}
3
  • 4
    Might be an idea to note that users should be very careful about redefining macros and only do so when they are exactly sure they know what the original macros does and that it is OK to change it. \span is the obvious example of what not to change.
    – daleif
    Commented Feb 12, 2014 at 11:27
  • @daleif - Excellent point! :-) I'll add an explicit note about this to my answer.
    – Mico
    Commented Feb 12, 2014 at 11:56
  • Wouldn't it be safer to save the old definition just in case?
    – cfr
    Commented Dec 3, 2015 at 0:03
-1
$rank_u{(n_i)}=\overline{w_i} +\max_{n_j\in\succ(n_i)}(\overline{c_i,_j}+rank_u{(n_j))}$


$rank_u{(n_i)}=\overline{w_i} +\max_{n_j\in\succ(n_i)}(\overline{c_i,_j}+rank_u{(n_j))}$
1
  • 2
    And the magic is what? Don't just dump some code. Commented Dec 14, 2015 at 6:15

You must log in to answer this question.

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