Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a way to define a command in a way, that a possible subsequent subscript is hidden? something like

\newcommand{\mycommand}[1]{#1\nosubscript}

analogously to math operators and \limit if i want the subscript below.

The background is, that I want to be able to define commands for beamer with overlays, that do not show the subscripts at all on specific slides. I try to avoid having to include the subscripts as parameters of the commands.

What I would like to achieve, is for example a redefined command \underbrace with an overlay specification, such that

$\underbrace<3>{x < 0}_{x \text{ negative}}$

will display the underbrace including its subscript only at on specified overlays, and just x < 0 otherwise.

share|improve this question
    
Do you really need to keep the syntax? Something like \xunderbrace<3>{x<0}{x \text{ negative}} is easier to implement and as good to input. –  egreg Jun 21 '12 at 13:45
add comment

2 Answers

Just defining

\def\mycommand#1_#2{#1}

should do the trick.

If you use

\usepackage[intlimits]{amsmath}

you don't need \limits for sums and the above works there too.

Combining my above try and Claudio's idea you should be able to do:

\def\uncoversubscript<#1>#2_#3%
    {#2_{\uncover<#1>{#3}}}
share|improve this answer
    
Thank you. I'm afraid I didn't state what I need appropriately, my apologies. I edited my Question. –  IARI Jun 21 '12 at 8:07
add comment

A first trial is:

\newcommand<>{\uncoversubscript}[2]{#1_{\uncover#3{#2}}}

Example:

\documentclass{beamer}

\usepackage{amsmath,amssymb}
\newcommand<>{\uncoversubscript}[2]{%
      #1_{\uncover#3{#2}}}

\begin{document}
\begin{frame}{Test}
\[\uncoversubscript<2>{x}{y} \uncoversubscript<2>{z}{1}\]
\end{frame}
\end{document}

Frames of the result:

enter image description here

enter image description here

Second attempt (not perfect):

\documentclass{beamer}

\usepackage{amsmath,amssymb}

% code by canaaerus
\def\uncoversubscript<#1>#2_#3%
    {#2_{\uncover<#1>{#3}}}

% code by Hendrik Vogt - http://tex.stackexchange.com/a/5465/13304
\makeatletter
\let\saved@underbrace\underbrace
\renewcommand<>*\underbrace[1]{\@ifnextchar_{\ub@with<2>{#1}}{\ub@without{#1}}}
\def\ub@with<#1>#2_#3{\mathpalette\underbrace@i{{#2}_{\only<#1>{#3}}}}
\newcommand*\ub@without[1]{\mathpalette\underbrace@i{{#1}{}}}
\newcommand*\underbrace@i[2]{\underbrace@ii#1#2}
\newcommand*\underbrace@ii[3]{\saved@underbrace{#1#2}#3}
\makeatother


\begin{document}
\begin{frame}{Test}
\[ \uncoversubscript<2->x_y \hspace*{2cm} \underbrace{x}_{y} \]


\end{frame}
\end{document}

I mess how to pass here \renewcommand<>*\underbrace[1]{\@ifnextchar_{\ub@with<2>{#1}}{\ub@without{#1}}} the current overlay specification to change <2>.

share|improve this answer
    
Thank you, but that includes the subscript within the command, so it can't be used as stated in the example with underbrace –  IARI Jun 21 '12 at 8:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.