Text Formattingweird problem with ifthenelse and subsections

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
poppi
Posts: 1
Joined: Sat May 15, 2010 8:20 am

weird problem with ifthenelse and subsections

Post by poppi »

Hello dear community,
I want to use optional bracketed tags in subsection-headlines, e.g. something like:

Definition (Definitionname)

whereas "Definition" is the constant part and "(Definitionname)" is an additional tag; if no tag is specified, just the constant part shall be created:

Definition

The LaTex code to invoke such a Definition-environment shall look like:

Code: Select all

  \begin{definition}{Definitionname}{Some text ...}
  \end{definition}
for an additional tag, or

Code: Select all

  \begin{definition}{}{Some text ...}
  \end{definition}
for no given tag. For the optional part, I use the ifthen-package, but it seems that it cannot be used in subsections? The LaTex-Code below shows the related part of my document, and it works for "always-defined" tags, since I commented out the failure-part for optional tags.

Code: Select all

\documentclass[a4paper,10pt]{article}

\usepackage{ifthen}

\newcommand{\bracketedname}[1]{
%  \ifthenelse{\equal{#1}{\empty}}{ }{\ (#1)}
  (#1)
}

\newenvironment{definition}[2]{
  \subsubsection{Definition \bracketedname{#1}} #2
}{}

\begin{document}

\begin{definition}{Definitionname}{Some text ...}
\end{definition}

\end{document}
If I activate the line

Code: Select all

%  \ifthenelse{\equal{#1}{\empty}}{ }{\ (#1)}
instead of using the line

Code: Select all

  (#1)
I get the following error message:

Code: Select all

! Undefined control sequence.
<argument> \equal 
                  {Definitionname}{\empty }
l.16 ...definition}{Definitionname}{Some text ...
Has anyone a solution for this? :roll: I would be very thankful for that ;)

Thank you in advance,
poppi 8-)

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply