Code: Select all
\documentclass{article}
\def\f{F}
\def\f(#1){F(#1)}
\def\f(#1,#2){F_{#1}^{#2}}
\begin{document}
$\f$
$\f(1)$
$\f(1,2)$
\end{document}
Thanks.
Code: Select all
\documentclass{article}
\def\f{F}
\def\f(#1){F(#1)}
\def\f(#1,#2){F_{#1}^{#2}}
\begin{document}
$\f$
$\f(1)$
$\f(1,2)$
\end{document}
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Code: Select all
\documentclass{article}
\begin{document}
\makeatletter
\def\f{\@ifnextchar(\@f F}
\def\@f(#1){\@@f(#1,,)}
\def\@@f(#1,#2,#3){%
\ifx\relax#2\relax
F(#1)%
\else
F_{#1}^{#2}%
\fi}
\makeatother
$\f$
$\f(1)$
$\f(1,2)$
\end{document}
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis