\documentclass{article} \usepackage{float} \usepackage{tikz,caption} \usepackage{ifthen} \begin{document} \newcommand{\titlename}[1] {% \ifthenelse{\equal{#1}{a}}{First}{}% \ifthenelse{\equal{#1}{b}}{Second}{}% } \foreach \y in {a,b}{ \foreach \a in {No,Yes}{ \begin{table}[H] \captionsetup{width=.9\linewidth}% \caption{\protect\titlename{\y}, \a ~Other Text} \end{table} } } \end{document}