Math & ScienceOptimization: Max of x and placing x underneath Max

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Optimization: Max of x and placing x underneath Max

Post by latexhelp1 »

I would like to write Max_x to denote that I'm going to maximize an expression with respect to x.

Currently, I write

Code: Select all

$Max_x$
That places the x diagonally to the right.

How would I place the x directly underneath the max? Like placing it underneath the a in Max?

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Optimization: Max of x and placing x underneath Max

Post by localghost »

There is a predefined operator exactly for this purpose.

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}

\begin{document}
  \[
    \max_x
  \]
\end{document}

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

Optimization: Max of x and placing x underneath Max

Post by Stefan Kottwitz »

If you would really need Max, and not the already defined operator \max, I would declare an operator for it. \limits causes the subscript to be written below the expression.

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\Max}{Max}
\begin{document}
$\Max\limits_x$
\end{document}
Stefan
LaTeX.org admin
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Optimization: Max of x and placing x underneath Max

Post by latexhelp1 »

Thank you both Stefan and Thorston.

I am trying to do this in beamer and within equation mode for a specific purpose, and neither seems to work.

I can only get it to compile with:

Code: Select all

\documentclass{beamer} %
\usetheme{CambridgeUS}
\usepackage[latin1]{inputenc}
\usefonttheme{professionalfonts}
\usepackage{times}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}

\begin{frame}
\frametitle{Frame Title}

\begin{equation*}
        \tikz[baseline]{
            \node[fill=blue!20,anchor=base] (t1)
            {$Max_f$};
        }
\end{equation*}

\end{frame}
\end{document}
Stefan_K wrote:If you would really need Max, and not the already defined operator \max, I would declare an operator for it. \limits causes the subscript to be written below the expression.

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\Max}{Max}
\begin{document}
$\Max\limits_x$
\end{document}
Stefan
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Optimization: Max of x and placing x underneath Max

Post by Stefan Kottwitz »

My code example works, also in your example code, producing this TikZ node:
max-operator.png
max-operator.png (1.5 KiB) Viewed 25225 times
latexhelp1 wrote:I can only get it to compile with
Perhaps don't show some other code, that works for you, but show the code you tried which doesn't work, so we could tell you the cause of the problem.

Stefan
LaTeX.org admin
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Optimization: Max of x and placing x underneath Max

Post by latexhelp1 »

Stefan,

The code in:
http://latex-community.org/forum/viewto ... 45&t=17758

I cannot get the Max to work in it.
Stefan_K wrote:My code example works, also in your example code, producing this TikZ node:

Perhaps don't show some other code, that works for you, but show the code you tried which doesn't work, so we could tell you the cause of the problem.

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

Optimization: Max of x and placing x underneath Max

Post by Stefan Kottwitz »

latexhelp1 wrote:I cannot get the Max to work in it.
If I use exactly my code in this example, it works. Perhaps you forgot the \DeclareMathOperator line, or you did something else. Who should guess what's wrong if you don't show it. In other cases you posted good minimal examples.

Stefan
LaTeX.org admin
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Re: Optimization: Max of x and placing x underneath Max

Post by latexhelp1 »

Never mind! I had made a typo. Thank you Stefan!! :)
Post Reply