Text FormattingSkip/include line based on parameter

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
pthowe
Posts: 17
Joined: Thu Mar 25, 2010 5:47 am

Skip/include line based on parameter

Post by pthowe »

I am trying to have a macro include an additional line only when the parameter contains the character "*". I just can not see how to accomplish this goal.

Here is a simple version of the macro:

Code: Select all

\newcommand{\formStep}[1]{
\begin{tabular}[t]{ll}  	
\ifnum{\value{#1}} %need to do if line only if "*" present in #1
	& \color{red}{* Yell UTZ} \\
	 \\
\fi
\end{tabular}
}

%code in document
\formStep{2} // no line

\formStep{2*} // line

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

pthowe
Posts: 17
Joined: Thu Mar 25, 2010 5:47 am

Skip/include line based on parameter

Post by pthowe »

This seems to work.

Code: Select all

%macro
\def\gobbleminus#1{\ifx-#1\else#1\fi}
\def\IsInteger#1{%
  TT\fi
  \ifcat_\ifnum9<1\gobbleminus#1 _\else A\fi
}

%document macro code
\if\IsInteger{#1} 
\else 
	&	\color{red}{* Yell UTZ} \\  	
\fi
Post Reply