निरंजन
The question says it all. An example:


\iffontsize{small}[TRUE}{FALSE}

Skillmon
I'm not aware of any package implementing something like that. However there are two approaches one could take:

The standard font size related macros (like \small and \huge for instance) set an internal macro called \@currsize to be equal to the last activated font size, so we can test against that:


\newcommand\iffontsizeTF[1]
{%
\expandafter\ifx\csname #1\endcsname\@currsize
\expandafter\@secondofthree
\fi
\@secondoftwo
}

This might require

\providecommand\@secondofthree[3]{#2}


However, if the current font size was set via \fontsize directly that macro will not be updated, in that case we can check via \f@size (which in LaTeX should always be set to the current font size in pt). An unexpandable test to check for this could be done by locally changing the font size and evaluating \f@size in that group. That's what the following does:


\newcommand\iffontsizeTF[1]
{%
\begingroup
\csname #1\endcsname
\expandafter
\endgroup
\expandafter\ifdim\f@size pt=\f@size pt
\expandafter\@secondofthree
\fi
\@secondoftwo
}


To implement an expandable test that would work in both cases we have to utilize some internals of the standard font size changing macros (this could break if the macros in question are altered). Internally the standard macros are implemented using an auxiliary called \@setfontsize which will take three arguments: The name of the switch (e.g., \small), the size and the baselineskip. This auxiliary is named <csname><space> (since they use the old protection mechanism of LaTeX).

The following implementation uses quite a few implementation tricks, most notably it uses \iffalse{\fi <stuff>} to get an unmatched closing brace that we use to gobble the remainder of the font size changing (we have to manually balance it again using \expandafter{\iffalse}\fi later). Also, since this includes unbalanced braces we have to make sure that the macro fully expands before introducing them, hence we directly start with \ifdim. The \space in our auxiliary macro \iffontsize@ is used to end TeX's number parsing after #3pt is processed (but only end it after the remainder of our unbalanced list was removed, hence we use the strange \expandafter\@firstoftwo\expandafter\space\expandafter{\iffalse}\fi construct).


\newcommand\iffontsizeTF[1]
{%
\ifdim % <- starts an expanding context
\f@size pt=%
\@ifundefined{#1 }%
{-\maxdimen\fi}% <- error case, this should result in the false branch
{%
\iffalse{\fi
\expandafter\expandafter\expandafter\iffontsize@\csname #1 \endcsname
}% <- an unbalanced closing brace serving as a marker
}%
\expandafter\@secondofthree
\fi
\@secondoftwo
}
\long\def\iffontsize@#1\@setfontsize#2#3%
{#3pt\expandafter\@firstoftwo\expandafter\space\expandafter{\iffalse}\fi}


If you don't need an expandable version I'd opt for the second code (this seems like the safest implementation), else I'd pick the first if \fontsize doesn't have to be supported, and the last one only as a last resort (though that's the one I had the most fun coding...).

-----

The following is a complete document using the last code variant (but you could swap it out for the other two as well, the first variant won't get the last usage right):


\documentclass[]{article}

\makeatletter
\providecommand\@secondofthree[3]{#2}
\newcommand\iffontsizeTF[1]
{%
\ifdim % <- starts an expanding context
\f@size pt=%
\@ifundefined{#1 }%
{-\maxdimen\fi}% <- error case, this should result in the false branch
{%
\iffalse{\fi
\expandafter\expandafter\expandafter\iffontsize@\csname #1 \endcsname
}% <- an unbalanced closing brace serving as a marker
}%
\expandafter\@secondofthree
\fi
\@secondoftwo
}
\long\def\iffontsize@#1\@setfontsize#2#3%
{#3pt\expandafter\@firstoftwo\expandafter\space\expandafter{\iffalse}\fi}
\makeatother

\newcommand\test[2]{{#1\iffontsizeTF{#2}{}{not }#2\par}}

\begin{document}
\test\small{small}
\test\huge{huge}
\test\small{huge}
\test\huge{small}

{%
\fontsize{9}{11}\selectfont% <- that's \small without some other settings
This is \iffontsizeTF{small}{}{not }small
}

{%
\small
\fontsize{30}{30}\selectfont
This is \iffontsizeTF{small}{}{not }small
}
\end{document}


![iffontsize.png](/image?hash=0e43dc3b44c83b0f8c40ca9eacc53d9888d1d96aa1ca568bfb2327ace345903b)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.