Introduction
Learning how to write argmax and argmin in LaTeX trips up more students and researchers than almost any other piece of math notation. The operators look simple on paper, yet typesetting them correctly takes a specific set of commands. Search data from this site shows the page on argmax in LaTeX drawing more than 6,200 impressions in a single 90 day window, proof that demand is steady. The core problem is placing the condition directly beneath the operator instead of off to its side. Most people reach for a plain command, see the subscript drift sideways, and assume LaTeX is broken. The fix lives inside the amsmath package and a small family of related commands. This guide walks through every reliable method, from a one line declaration to manual placement with underset. By the end you will know exactly which approach fits a quick note, a thesis, or a published paper.
Quick Answers on Writing Argmax and Argmin in LaTeX
How do you write argmax in LaTeX with the condition centered below it?
To write argmax in LaTeX, load the amsmath package and use the starred operatorname form so the condition sits centered below the operator in display style.
What is the cleanest way to reuse argmax across a whole document?
Declare a reusable macro for argmax in LaTeX with the starred DeclareMathOperator command in your preamble, then call that short macro anywhere in the document.
Can you write argmax in LaTeX without editing the preamble?
Yes, you can write argmax in LaTeX with the underset command or the starred operatorname form inside a single equation, with no preamble edits required at all.
Key Takeaways for Typesetting Argmax and Argmin
- The amsmath package is the foundation for clean argmax and argmin, supplying
\operatornameand\DeclareMathOperator. - The star form, written with an asterisk, is what pushes the condition below the operator in display equations.
- For repeated use, declare a custom operator once in the preamble and call the short macro throughout the document.
- For a single equation,
\undersetor\operatorname*avoids touching the preamble at all.
Table of contents
- Introduction
- Quick Answers on Writing Argmax and Argmin in LaTeX
- Key Takeaways for Typesetting Argmax and Argmin
- What Is Argmax in LaTeX?
- What Argmax and Argmin Mean in LaTeX
- How Argmax Operators Behave Inside Math Mode
- The amsmath Package: The Foundation for Argmax
- Using operatorname for a Quick Argmax
- Declaring a Reusable Argmax with DeclareMathOperator
- Controlling the Subscript with limits and nolimits
- The underset Method for Argmax and Argmin
- Getting the Spacing Right with arg max
- Writing Argmin the Same Way as Argmax
- Argmax with Subscripts, Conditions, and Constraints
- Common Argmax and Argmin Risks and Mistakes in LaTeX
- Argmax in Overleaf and Online Editors
- Argmax Notation in Machine Learning Papers
- The Ethics and Future of Math Operators in LaTeX and Web Rendering
- How to Write Argmax and Argmin in LaTeX: Step by Step Implementation
- Key Insights on Argmax and Argmin Typesetting
- Comparing the Four Ways to Write Argmax in LaTeX
- Real LaTeX Argmax Examples That Render Cleanly
- Lessons From Documents That Got Argmax Wrong
- Frequently Asked Questions About Argmax and Argmin in LaTeX
What Is Argmax in LaTeX?
Knowing how to write argmax and argmin in LaTeX means using amsmath, where a starred operatorname or declared argmax macro centers the condition below the operator.
An Interactive From AIplusInfo
Argmax and Argmin LaTeX Builder
Pick an operator and a method, then see the exact LaTeX code and where the condition lands on the page.
Method behavior follows the amsopn manual for amsmath operators.
What Argmax and Argmin Mean in LaTeX
Before typesetting anything, it helps to know what these operators actually express. The arg max operator returns the input that maximizes a function, not the maximum value itself. When a function peaks at a point, max gives you the height of that peak while arg max gives you the location. The two answers are different objects, and the notation has to make that distinction clear. The arg min operator works in mirror image, returning the input that drives a function to its lowest value. Both ideas appear constantly in optimization, statistics, and machine learning. The arg max definition on Wikipedia stresses that the output can be a set, since several inputs may tie for the maximum.
That set valued nature is why authors write a condition under the operator. The subscript names the domain you are searching over, such as all real numbers or a finite list of classes. Writing arg max without that subscript leaves the statement ambiguous and incomplete. A reader needs to see the variable and its range to interpret the expression. This is the same visual logic that governs summation and limit operators. Each one carries an index sitting directly beneath the symbol. Treating arg max the same way keeps your equations readable and conventional.
The connection to other operators matters for typesetting choices later. Operators like sum and lim use the star behavior by default, placing their index below in display mode. Plain text functions like sin and log keep everything on one line because they never take a lower index. Arg max and arg min belong firmly in the first group, alongside lim and max. That single fact explains every command decision in this guide. If you keep the comparison to a summation in mind, the rest follows naturally. You can review how related operators behave in the glossary of AI terms for added context.
How Argmax Operators Behave Inside Math Mode
Building on that comparison, the trouble starts the moment you type the letters directly. Writing argmax as bare letters makes LaTeX render them in italics, as if each one were a separate variable. The output looks like a product of the variables a, r, g, m, a, and x rather than a named operator. Spacing collapses, and the result reads as gibberish to a trained eye. LaTeX has no built in knowledge that arg max is a function name. You must declare that intent through a dedicated operator command so the engine treats the name as a single unit. Only then does the engine set the name in upright roman type with correct spacing.
The second issue is where the condition lands once you add a subscript. A naive subscript attaches to the right of the operator, the way a power or index would. For a display equation, convention demands the condition sit centered underneath instead. Achieving that placement requires the star form of an operator command or an explicit limits instruction. These two problems, upright type and subscript position, are the whole challenge. Every method described below solves both of those problems at once, which is what makes them reliable. The Overleaf operators guide demonstrates the same italic versus upright distinction with other functions.
The amsmath Package: The Foundation for Argmax
Turning to the toolkit itself, almost every reliable method depends on one package. The amsmath package supplies the operator commands that make argmax in LaTeX behave correctly. You load it once near the top of your document and gain access to a whole family of math tools. Without it, the cleanest commands simply do not exist, and you fall back on fragile manual tricks. The package is maintained by the American Mathematical Society and ships with every standard distribution. That ubiquity means your code stays portable across machines and editors. Adding it costs a single line and unlocks the rest of this guide.
Loading the package looks like the snippet below, placed in the preamble before the document begins. The line sits alongside any other packages you already use, and order rarely matters here. Most templates from journals and universities already include it for you. If your file compiles math at all, there is a good chance amsmath is present. You can confirm by searching the preamble for the usepackage line. When in doubt, add it, since loading it twice causes no harm.
\usepackage{amsmath}
Beyond operators, amsmath improves spacing, multiline equations, and matrix environments across your document. It is the same package behind the align environment that researchers rely on for numbered equations. Treating it as a default rather than an optional extra saves hours of debugging. The official documentation for operator names lives in the amsopn manual on CTAN. That manual is dense, but it confirms the exact behavior of every command in this article. For practical work, you rarely need to read past its first few pages. The key point is simple, since amsmath is the gate through which all clean notation passes. Mastering how to write argmax and argmin in LaTeX starts with this package and rarely needs anything more exotic.
Once the package is loaded, you have two main routes to a polished operator. One route declares a reusable command, while the other formats the operator on the spot. Both routes produce identical visual output when configured correctly, so the decision rests entirely on convenience. The choice comes down to how often you expect to type the operator. A paper that uses arg max forty times benefits from a declared macro. A single homework problem does not need that overhead, as the inline form works fine. Understanding both keeps you flexible across projects of any size.
Using operatorname for a Quick Argmax
Shifting to the fastest method, operatorname handles a one off operator without any preamble edits. The starred form, written as operatorname with an asterisk, places the condition below the operator in display math. You type the function name as an argument, and LaTeX sets it upright with proper spacing. The thin space command inside keeps arg and max visually separated. This approach is ideal when you only need the operator once or twice. It keeps everything local to the equation, so nothing leaks into the preamble. For quick answers and forum posts, it is often the cleanest choice.
The snippet below shows the starred form with a condition underneath. Notice the asterisk directly after the command, which is the part that controls placement. Drop the asterisk and the subscript jumps to the side instead. The thin space marked by a backslash comma sits between arg and max for readability. You can swap max for min to produce arg min with no other change. This symmetry makes the command easy to remember under pressure.
$$\operatorname*{arg\,max}_{x \in S} f(x)$$
One caveat deserves attention before you commit to this method everywhere. In inline math, the condition moves to the side even with the star, because inline style suppresses limits. That behavior is intentional and matches how sum behaves inside a sentence. If you need the condition below inline, you add a limits instruction explicitly. For display equations, the star alone does the job perfectly. The LaTeX-Tutorial operators lesson shows the same inline versus display contrast with screenshots. Keeping that inline versus display distinction in mind prevents one of the most common surprises beginners hit.
Declaring a Reusable Argmax with DeclareMathOperator
Stepping back to the broader toolkit, the declared operator is the professional standard for longer documents. A single DeclareMathOperator line in the preamble creates a short macro you can call anywhere. The starred version of the command makes that macro place its condition below, exactly like operatorname does. After declaring it once, you stop worrying about spacing and placement entirely. Every call produces identical output, which keeps a long paper visually consistent. This consistency is precisely what reviewers and typesetters look for. The approach scales from a short report to a full dissertation without extra effort.
The declaration takes two arguments, the macro name and the text to display. You write the operator text with a thin space so it reads arg max rather than argmax. The same pattern defines arg min by changing the displayed text. Placing both declarations together in the preamble keeps them easy to find later. The snippet below shows the full setup for both operators at once. Many lab templates ship with these two lines already present.
% in the preamble
\usepackage{amsmath}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
% in the body
$$\argmax_{x \in S} f(x) \qquad \argmin_{x \in S} f(x)$$
The detail that catches people is the asterisk on the declaration command. Without it, the macro behaves like a plain function and pushes the subscript sideways. The starred form is the one that gives summation style placement below the operator. This single character is the most common point of failure in real documents. If your declared argmax shows its condition on the side, check for a missing asterisk first. The behavior is documented precisely in the amsopn manual that ships with amsmath. Patterns like this also appear when you study reusable code in machine learning algorithms where notation repeats often. For long projects, knowing how to write argmax and argmin in LaTeX really means declaring the operator one time.
Controlling the Subscript with limits and nolimits
Beyond the star form, two explicit commands give you direct control over placement. The limits instruction forces the condition below the operator, while nolimits keeps it to the side. You append either command right after the operator and before the subscript. This override works whether the operator was declared with or without a star. It is the escape hatch for the inline math case mentioned earlier. When the star alone is not enough, these commands settle the matter. They give you the final say over every operator in your document.
The snippet below forces the condition underneath even inside an inline expression. Use the limits form sparingly, since most readers expect inline operators to stay compact. For display equations, the star already handles placement, so these commands are redundant there. Knowing they exist still matters for the awkward edge cases. The same toggle appears with custom operators built for fields like statistics, as covered in joint probability formulas notation. Reach for limits only when the default placement fights you.
$\operatorname*{arg\,max}\limits_{x \in S} f(x)$
The underset Method for Argmax and Argmin
Looking for an approach that skips operator declarations entirely, underset offers manual control. The underset command places any content directly beneath a symbol, including a condition under arg max. You give it two arguments, the text to sit below and the symbol above. This method needs amsmath for the cleanest spacing but avoids declaring a custom operator. It shines for one off constraints that you will never reuse. Many forum answers reach for it because it reads literally in the source. The downside is that you control spacing yourself, with no operator level help.
The snippet below shows the construction that users frequently search for verbatim. Notice that arg max here is written with explicit backslash commands for arg and max. The underset wrapper then drops the variable and its domain beneath the pair. This exact pattern appears in clustering and assignment problems across many papers. It is also the form people paste from older blog posts and answers. The result looks correct, though it lacks the upright operator styling a declaration provides.
$$\underset{x \in C}{\operatorname{arg\,max}}\; \left| \mu_c - \mu_{c} \right|$$
There is a subtle tradeoff between underset and the operator commands worth naming. Underset treats the stacked text as an ordinary subscript, not as an operator index, which can shift spacing slightly. For most readers the difference is invisible, so the method remains popular. When you need pixel level consistency across a long document, prefer a declared operator instead. For a quick constraint in a single equation, underset is hard to beat. You can compare how different placement choices read by toggling the interactive builder near the top of this page. That hands on view makes the tradeoff concrete in seconds.
Getting the Spacing Right with arg max
Turning to a detail that separates polished work from rushed work, spacing inside the operator matters. A thin space written as a backslash followed by a comma keeps arg and max visually distinct. Without it, the letters crowd together and read as a single clumsy token. The thin space measures three eighteenths of a quad, a small but deliberate gap. Professional templates always include that thin space inside the operator text so the spacing never looks rushed. The same convention applies to arg min and any multi word operator name. This tiny habit makes your equations look typeset rather than typed.
You place the thin space once, inside the operator definition or the operatorname argument. After that single definition, every later call inherits the correct spacing automatically across the entire document. Avoid the temptation to use a full word space, which looks too wide in math. The thin space is the standard that journals and the amsmath authors expect. The snippet below contrasts the cramped and spaced versions so the difference is obvious. Once you see them side by side, you will never skip the thin space again.
$\operatorname*{argmax}_{x}$ % cramped, avoid
$\operatorname*{arg\,max}_{x}$ % correct thin space
Writing Argmin the Same Way as Argmax
Building on that same logic, the partner operator arg min needs no new technique at all. Every method that produces arg max produces arg min by swapping the displayed text from max to min. The amsmath foundation, the star form, and the underset trick all transfer unchanged. This symmetry is why the two operators almost always appear together in guides. Search demand confirms it, since argmin queries arrive on this page nearly as often as argmax. Treating them as a pair saves you from learning two separate workflows. One mental model therefore covers both operators, which is why guides almost always present them as a pair.
In practice you declare both operators side by side in the preamble. That keeps your notation consistent whether a proof minimizes loss or maximizes likelihood. Optimization writing flips between the two constantly, so consistency pays off. A model that minimizes a loss function uses arg min, while a classifier picking a label uses arg max. Both ideas show up when you study a topic like cross-entropy loss functions and its optimization. Declaring the pair together mirrors how the math itself pairs them.
The snippet below sets both operators in one display line for direct comparison. Notice how the only change between them is the three letter operator name. The placement, the spacing, and the subscript handling all stay identical between the two operators. This is the payoff of the declared operator pattern shown earlier. If you can write one, you can write the other without a second thought. The visual result reads cleanly in any journal template you are likely to encounter as a researcher. Once you understand how to write argmax and argmin in LaTeX, the two operators feel like a single skill.
$$\hat{x} = \argmax_{x \in S} f(x), \qquad \check{x} = \argmin_{x \in S} f(x)$$
Argmax with Subscripts, Conditions, and Constraints
Moving on to richer expressions, real research rarely stops at a single variable underneath the operator. The subscript under arg max can hold a set membership, an inequality, or several conditions stacked together. You write the full condition inside the subscript braces, and LaTeX keeps it centered below. For multiple lines, the substack command stacks conditions neatly under the operator. This handles constrained optimization where the feasible region needs description. The pattern matches how summation indices grow more detailed in advanced work. Mastering it lets you typeset any optimization statement you meet.
The substack command lives in amsmath and accepts lines separated by a double backslash. Each line sits centered under the operator, building a compact multi condition index. This is far cleaner than cramming everything onto one wide line. The snippet below shows a two line condition under arg max. You can extend it to three or more lines without any new command. The result stays readable even when the constraint set is complex.
$$\operatorname*{arg\,max}_{\substack{x \in S \\ x > 0}} f(x)$$
Conditions can also reference parameters defined elsewhere in your document. A classifier might maximize over a label set, while an estimator maximizes over a parameter space. The notation adapts to either case by changing only the subscript content. Keeping the operator command fixed and varying the subscript is the disciplined approach. It mirrors how flexible function design works in classification and regression trees. The operator stays stable while the domain it searches changes.
For very wide conditions, consider breaking the equation across lines with an align environment. The operator and its subscript stay together while the rest of the expression wraps. This prevents the dreaded overfull line that pushes math into the margin. The align environment again comes from amsmath, reinforcing why that package is central. Plan your equation layout before the expression grows unwieldy, since fixing overfull lines later wastes real time. A little structure planned up front keeps even complex constrained objectives legible on the printed page.
Common Argmax and Argmin Risks and Mistakes in LaTeX
Shifting from what works to what breaks, a handful of errors account for most failures. The single most frequent mistake is omitting the asterisk that controls subscript placement. A close second is forgetting to load amsmath, which makes the operator commands undefined. Typing the bare letters without an operator command produces italic gibberish, the third common slip. Each of these has a one line fix once you recognize the symptom. The patterns repeat across thousands of forum questions on the topic. Learning to spot them turns a frustrating hour into a quick correction.
Another subtle error is mixing up inline and display expectations, which produces placement that looks wrong to readers. Writers expect the condition below in a sentence, then wonder why it sits sideways. The answer is that inline math suppresses limits by design, as noted earlier. Adding the limits command or using a display environment resolves it. A final pitfall is inconsistent spacing, where some operators use the thin space and others do not. Declaring the operator a single time in the preamble removes that spacing inconsistency for good. The table later in this guide maps each mistake to its fix.
Copy and paste introduces its own class of problems worth flagging. Snippets from old blog posts sometimes use commands that predate amsmath conventions. Others rely on packages you have not loaded, causing cryptic errors. Always check that pasted code declares its operator and loads amsmath. When debugging, isolate the equation in a minimal file to find the culprit. This disciplined habit saves time, much like careful data checks in pandas melt for machine learning workflows. A clean minimal example strips away noise and exposes the real source of the error fast.
Argmax in Overleaf and Online Editors
Turning to where most people actually write today, Overleaf and similar editors behave the same as a local install. Overleaf includes amsmath in nearly every template, so the operator commands work out of the box. You declare your operator in the main file preamble exactly as you would offline. The live preview then shows placement instantly, which speeds up debugging. If a command is undefined, the editor flags the missing package right away. This immediate feedback makes Overleaf a forgiving place to learn the notation. The portability of amsmath means your code moves between editors without edits.
One Overleaf specific tip helps when collaborating on a shared paper. Keep your operator declarations in a single preamble file that every author imports. That single shared file prevents duplicate or conflicting operator definitions across chapters and coauthors. The same caution applies to any tool that splits a document into many files. Define the operators once, import that file everywhere, and the notation stays uniform throughout the project. The Overleaf operators guide walks through declaring custom operators with live examples. Following it keeps a multi author project consistent from the first page to the last. Teams adopting a new toolchain, such as machine learning in Julia, gain from the same import once discipline.
Argmax Notation in Machine Learning Papers
Turning to its most common home, machine learning papers lean on arg max constantly in their methods. The arg max operator is the decision rule that turns model scores into a predicted class. A network outputs a vector of scores, and arg max selects the index of the largest one. That index is the predicted label, which is why the operator appears in nearly every classification paper. The same notation describes maximum likelihood estimation and policy selection in reinforcement learning. Writing it cleanly signals that you understand the field conventions. Reviewers do notice sloppy operator typesetting, fair or not, so clean notation quietly helps your submission.
The code side of machine learning mirrors the math side closely, which makes the notation feel concrete. Libraries expose the operation directly, so the notation maps onto a single function call. The torch.argmax documentation describes returning the index of the maximum value along a dimension. That index is exactly what the math subscript selects, which makes the link tangible for practitioners. Seeing the equation and the code together cements the concept. This connection between symbol and implementation runs through PyTorch loss functions as well. The math notation is not decoration, since it specifies the computation precisely.
For full length papers, the declared operator pattern is almost mandatory because the operator recurs so often. A typical methods section references arg max many times across objectives and decision rules. A single declaration keeps all of them consistent, which a typesetter will appreciate. It also makes global changes trivial if a reviewer requests different notation. The discipline parallels how reusable components keep code clean across technical writing. Define the operator once and let every objective inherit the same polished look.
The Ethics and Future of Math Operators in LaTeX and Web Rendering
Looking ahead, the way we render math is shifting from print toward the browser. Web renderers like MathJax and KaTeX now support the same operator commands that LaTeX uses. That means a declared arg max can travel from a paper to a blog post with little change. The convergence lowers the cost of writing notation once and reusing it everywhere. As more research lands on the web first, this portability grows in value. The operator commands you learn today will keep working across these surfaces. Notation is steadily becoming a write once, render anywhere asset that moves across print and the web.
Accessibility is the second force shaping the future of math typesetting. Screen readers parse structured math better when operators are declared rather than faked with raw letters. A properly declared arg max can be announced as a named operator, not a string of variables. This matters for readers who rely on assistive technology to follow proofs. Standards bodies are pushing math markup that preserves this structure. Writing clean operators today makes your work more inclusive tomorrow. The accessibility benefit compounds as more research documents move online and reach assistive technology users. Learning how to write argmax and argmin in LaTeX today also serves the ethical duty of accessible web rendering.
Tooling is the third trend worth watching closely, since it quietly shapes how most writers learn notation. AI assistants now generate LaTeX, and they often default to the declared operator pattern. That nudges more writers toward the correct approach without reading a manual. At the same time, Unicode math and newer LaTeX engines simplify some older workarounds. The core idea stays the same, since an operator must be named and placed deliberately. You can track how tooling reshapes technical work in pieces on machine learning vs deep learning. The chart below shows how search interest splits across these argmax and argmin queries today.
Chart From AIplusInfo
Search Demand for Argmax and Argmin LaTeX Queries
Google impressions over 90 days for the top queries reaching this page.
Source: AIplusInfo Google Search Console data, 90-day window, top queries by impressions.
How to Write Argmax and Argmin in LaTeX: Step by Step Implementation
Pulling every method into one workflow, this section gives a repeatable recipe. Follow the steps in order and you will get clean argmax in LaTeX on the first compile. Each step is small, specific, and tested against the amsmath conventions described above.
Step 1 – Load the amsmath package
Open your preamble and confirm that the amsmath package loads before the document begins, ideally within the first 5 lines. This 1 package supplies the operatorname, DeclareMathOperator, limits, and substack commands used everywhere in this guide. If the line is missing, add it now so that every operator command resolves cleanly on the next compile. Loading the package twice causes no error, so include it even when you are not completely sure. Most journal and university templates already include amsmath for you, but a quick check costs only a moment. Pro tip: keep amsmath near the top of your package list to avoid load order surprises later. With the package present and confirmed, every later step in this workflow runs exactly as written here.
\usepackage{amsmath}
Step 2 – Declare your operators once
Add exactly 2 declaration lines to your preamble, one for arg max and one for arg min. Use the starred form of DeclareMathOperator so the condition sits centered below the operator in display math. Write the operator text with a thin space so the result reads arg max rather than the cramped token argmax. Place both lines together in the preamble so that future you can find and edit them in seconds. This one time setup pays off across the entire document, no matter how long it eventually grows. Pro tip: store these 2 declarations in a shared preamble file when several authors collaborate on one paper. After this step, a short macro replaces all of the verbose command typing you would otherwise repeat.
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
Step 3 – Call the macro in a display equation
In the body of the document, call your new macro inside a display math environment for the cleanest result. Add the search condition as a subscript using an underscore followed by braces around the variable and its domain. The starred declaration then places that condition centered beneath the operator automatically on the first compile. Verify in the preview that arg max appears upright with the variable sitting directly underneath it. If the 1 equation looks correct, your setup is complete for the entire document going forward. Repeat the very same macro call anywhere arg max appears, with no extra configuration required. That repetition is where the declared operator pattern saves the most time across a long manuscript.
$$\argmax_{x \in S} f(x)$$
Step 4 – Handle one off cases without a declaration
When you only need the operator 1 time, you can skip the declaration step entirely without any downside. Use the operatorname star form directly inside the equation to get the same centered placement below. Alternatively, wrap the condition with the underset command for fully manual control over the stacked text. Both routes produce a clean operator without touching the preamble or defining a custom macro. Choose operatorname when you want proper operator styling and underset when you want a quick visual stack. This flexibility suits short notes, homework problems, and quick forum replies where editing a preamble is impractical. The visual output matches the declared version closely in any display equation you write.
$$\operatorname*{arg\,max}_{x \in S} f(x)$$
$$\underset{x \in S}{\operatorname{arg\,max}}\; f(x)$$
Step 5 – Force placement when inline math fights you
Inside a sentence, inline math suppresses limits and pushes the condition off to the side of the operator. When you truly need it below inline, append the limits command directly after the operator name. Use this single override sparingly, since most readers expect inline operators to stay visually compact. For a standalone equation, the star already handles placement, so these 2 commands become redundant there. Pro tip: prefer a display equation over forcing limits inline for anything more complex than 1 short term. This final step closes the gap on the one case that the star form alone happens to miss. With it in hand, you now control placement in every context your document will ever need.
This inline form $\operatorname*{arg\,max}\limits_{x} f(x)$ keeps the condition below.
Key Insights on Argmax and Argmin Typesetting
- Search interest stays steady, with this site reporting 6,237 impressions over 90 days in its search console performance data, which justifies a thorough guide.
- Argmin demand rivals argmax, since the query argmin latex alone drew 1,164 impressions, a pattern a combined argmin and argmax guide is built to serve.
- The thin space adds a gap of three eighteenths of a quad, a rule the amsopn manual on CTAN treats as standard for operator names.
- The star form is the single switch that matters, because the Overleaf operators reference shows operatorname placing the index below only when an asterisk is present, which explains most failures.
- Notation maps directly to code, as the torch argmax reference page defines the operator as returning the index of the maximum value, the exact object the math subscript selects.
- Inline math behaves differently by design, which the LaTeX-Tutorial operators lesson illustrates by showing the condition shift sideways unless a limits override is added to the operator.
- Argmax can return more than one answer, a set valued property the arg max article on Wikipedia defines as distinct from the single value that the max operator produces.
Taken together, these points explain why a few small commands solve a problem that frustrates so many writers. The demand data shows that argmax and argmin matter to a large, ongoing audience across study and research. The technical rules reduce to two ideas, naming the operator and placing its condition deliberately below. Both ideas live inside amsmath, which is why that package anchors every method here. The link between the math symbol and the library function call makes the notation practical rather than ornamental. Mastering these commands once gives you clean optimization notation for the rest of your career.
Comparing the Four Ways to Write Argmax in LaTeX
Choosing among the four methods comes down to how often you type the operator and whether you can edit the preamble. The table below lines up operatorname, DeclareMathOperator, underset, and the manual form across the dimensions that matter most in practice. Use it as a quick reference whenever you start a fresh document and need to commit to one clear approach. A short report and a full dissertation rarely call for the same method, so match the chosen tool to the project at hand. The same selection mindset appears when picking between supervised and unsupervised algorithms for a modeling task. Pick deliberately at the start and the rest of your notation falls neatly into place.
| Dimension | operatorname star | DeclareMathOperator star | underset | manual arg max |
|---|---|---|---|---|
| Preamble edit required | No | Yes, one time | No | No |
| Condition below in display | Yes | Yes | Yes | No |
| Inline placement | Side unless limits added | Side unless limits added | Below | Side |
| Thin spacing handled | Yes, inside argument | Yes, in declaration | Manual | Manual |
| Reusable short macro | No | Yes | No | No |
| Upright operator styling | Yes | Yes | Partial | Weak |
| Best use case | One or two equations | Whole paper or thesis | Single constraint | Avoid in modern work |
| Learning curve | Low | Low after setup | Low | Low but error prone |
Real LaTeX Argmax Examples That Render Cleanly
These three worked examples show the exact LaTeX that renders argmax cleanly, each carrying its own tradeoff. Read them as templates you can paste and adapt rather than as abstract advice to memorize. The first favors raw speed, the second favors reuse, and the third favors a single one off constraint. Together they cover the situations most writers meet when typesetting optimization objectives in a paper. The same example driven approach helps when learning the AODE algorithm or the foundations in how neural networks work. Try each snippet in a live editor to confirm the placement for yourself.
The operatorname Star Snippet
This first snippet, used widely in quick answers, builds arg max with a single 1 line command and zero preamble changes. You write operatorname with an asterisk, pass arg max with a thin space, and add the condition as a subscript. In a display equation the outcome is exactly right, with the variable centered below the operator on the first compile. The one measurable win is brevity, since it takes just one line and no setup, saving minutes of manual spacing to produce journal quality placement. The limitation is inline behavior, because inside a sentence the condition slides to the side unless you append a limits command. The Overleaf operators reference demonstrates this exact star behavior with live previews. For one or two equations, this snippet is the most efficient option available.
The DeclareMathOperator Macro
This snippet is built from a reusable macro that you add as 2 lines in the preamble. You declare argmax and argmin with the starred command, then call the short macros throughout the body. The measurable payoff appears at scale, since a paper that uses arg max forty times now stays perfectly consistent with two setup lines. Every call inherits the same spacing and placement, saving hours of formatting and removing an entire class of inconsistency bugs. The limitation is the asterisk requirement, because dropping it silently moves the condition to the side on every call. The amsopn manual on CTAN spells out the star versus plain distinction precisely. For any document longer than a page, this is the professional default.
The underset Constraint Snippet
This snippet is built around a one off constrained arg max using underset instead of a declared operator command. You wrap the condition and the operator so the full constraint sits directly beneath arg max. The measurable benefit is flexibility, since a single line handles a complex 2 part condition without any preamble work. It is the exact construction many users have used verbatim for clustering and assignment objectives, saving minutes per equation. The limitation is spacing, because underset treats the stacked text as a plain subscript rather than an operator index, which can shift the gap by a hair. A focused walkthrough on the physicsread argmax tutorial shows the same underset pattern in context. For a single tricky constraint in one equation, the underset method remains the quickest route available.
Lessons From Documents That Got Argmax Wrong
Each lesson below comes from a recurring failure mode that turns up in real documents and busy forums. The pattern is almost always the same, a small omission that quietly breaks placement or spacing. Seeing the problem, the fix, and the measurable impact together makes the lesson genuinely stick. Use these three cases as a quick checklist before you submit a paper full of operators. The same debugging discipline pays off when tuning batch normalization in neural networks during model training. Learn the symptom once and you will spot it almost instantly the next time.
Case Study: A Thesis That Lost Its Subscripts
The problem in this common scenario is a thesis where every arg max showed its condition on the side instead of below. The author had declared the operator with DeclareMathOperator but omitted the trailing asterisk on all 30 or more calls. The solution was a single character edit, switching the declaration to the starred form so limits sit beneath the operator. That one change corrected every instance at once, since the macro propagates to all calls. The measurable impact was dramatic, fixing more than 30 equations with one preamble edit rather than 30 manual patches, saving hours of tedious rework. The limitation is that the symptom is easy to miss until a full compile, because the code looks correct at a glance. The star versus plain rule that drives this fix is documented in the amsopn manual on CTAN. The lesson is to check the asterisk first whenever conditions drift sideways.
Case Study: A Submission Flagged for Cramped Spacing
The problem here was a paper where arg max rendered as the cramped token argmax with no gap between the words. The author had defined the operator without the thin space, so the letters ran together on every page. The solution was to insert the thin space command inside the operator text, restoring the standard three eighteenths of a quad gap. After the edit, all instances read as arg max with proper separation, matching the surrounding journal style. The measurable impact was consistency across roughly 24 equations corrected through one declaration change, saving hours of copyediting late in the project. The limitation is subtlety, since cramped spacing reads as merely ugly rather than broken, so it often survives until a copyeditor flags it. The convention for that thin space appears in the LaTeX-Tutorial operators lesson. The lesson is to bake the thin space into the declaration so it can never be forgotten.
Case Study: A Web Article That Rendered Argmax in Italics
The problem in this web scenario was an article where arg max appeared as six italic variables strung together. The author had typed the bare letters in a MathJax expression without any operator command. The solution was to switch to operatorname so the renderer set the name upright with correct spacing, exactly as LaTeX does in print. The measurable impact was immediate legibility, turning 1 garbled expression into a clean operator that screen readers announce as a unit, saving minutes of reader confusion. The limitation is that web renderers vary, so a snippet that works in MathJax may need a small tweak in KaTeX. The same operator handling that fixes this is described in the Overleaf operators reference. The lesson is that the upright operator rule applies on the web just as firmly as it does on paper.
Frequently Asked Questions About Argmax and Argmin in LaTeX
To write argmax in LaTeX, load the amsmath package in your preamble before the document begins. Then use the starred operatorname form so the condition sits centered below the operator in display math. For repeated use, declare a short macro with the starred DeclareMathOperator command instead.
Argmin works exactly like argmax, with the displayed text changed from arg max to arg min. Declare it once with the starred DeclareMathOperator command, or use the starred operatorname form inline. Every method that produces argmax produces argmin with no other change required.
The most common cause is a missing asterisk on operatorname or DeclareMathOperator in your code. The starred form is what places the condition below the operator in display math. Inline math also pushes the condition sideways by design, unless you add an explicit limits command.
The operatorname command formats an operator inline within a single equation and needs no preamble change. The DeclareMathOperator command creates a reusable macro that you define once in the preamble. Both place the condition below the operator when you use the starred form. Choose the DeclareMathOperator command for any document longer than a single page or section.
Use the starred operator form and add the condition as a subscript with an underscore and braces. In a display equation the condition then centers below the operator automatically. For several conditions at once, use the substack command inside the subscript to stack the lines neatly.
Yes, the cleanest methods all depend on the amsmath package being loaded in your preamble. It supplies the operatorname, DeclareMathOperator, limits, and substack commands used across this guide. Without amsmath those commands are undefined, and you fall back on fragile manual workarounds.
The max operator returns the largest output value that a function reaches across its domain. Argmax instead returns the input point that produces that largest value, which is a different object. Argmax can also return a set when several inputs tie for the maximum value.
Overleaf includes the amsmath package in nearly every template, so the operator commands work immediately. Declare your operators in the main file preamble and then call them in the document body. The live preview shows placement instantly, which makes debugging argmax notation fast and forgiving.
You can write argmax inline with the starred operatorname form directly inside the equation. Alternatively, wrap the condition with the underset command to stack it under the operator name. Both approaches produce a clean operator in a single equation with no custom macro and no preamble change.
The thin space, written as a backslash followed by a comma, adds a small gap between arg and max. Without it the two words crowd together and render as the cramped token argmax. The gap measures three eighteenths of a quad, the accepted standard for multi word operator names.
Use the substack command inside the subscript braces to handle several conditions at once. Separate each condition with a double backslash so the lines stack centered below the operator. This keeps a complex feasible region readable instead of crowding everything onto one wide line.
The math subscript selects the input that maximizes a function over its domain. In code, the torch argmax function returns the index of the maximum value along a chosen dimension. That returned index is the predicted class in classification, so the symbol and the function describe one operation.
Yes, you append the limits command directly after the operator to force the condition below inline. Use this override sparingly, since most readers expect inline operators to stay visually compact. For anything complex, prefer a full display equation instead of forcing the placement inline.