Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following in my preamble:

\usepackage[overload, ntheorem]{empheq}
\usepackage[amsmath, thmmarks]{ntheorem}
\usepackage{mathtools}
\mathtoolsset{showonlyrefs,showmanualtags}
\newtagform{brackets}{[}{]}
\usetagform{brackets}

Further, I also have

\theoremheaderfont{\upshape}\theorembodyfont{\upshape}
\theoremstyle{nonumberplain}
\theoremseparator{}
\theoremsymbol{}
\newtheorem{optional}{}

So now I can make an empty environment which takes an optional argument like \begin{optional}[$H_2$]. This works but I get to see (H_2) while I would like to see [H_2]. How do I change this? It would be perfect if I could access the mathtools command that gives me the left bracket and the right bracket so I don't have to change it in multiple places if I would want to change it (I could of course define a new command for the left and right bracket but that feels like an ugly hack!).

I forgot to mention that if I give it a label, then refering to it should give the optional argument. Maybe there is a better solution to this problem. I have also tried an equation with \tag but \text doesn't do automatic line breaks.

Thanks for the suggestion. I fixed it like this, but I don't know if it is a good way:

\makeatletter
\newenvironment{optional}[1][Hypothesis]{
  \par\noindent \text{[#1]}
  \def\@currentlabel{[#1]}
}{\\}
share|improve this question

1 Answer 1

up vote 4 down vote accepted

Might be a better idea if you provide a full minimal example, for those not knowing it is not obvious that you a using ntheorem. As for you question. You will need to define an alternative theoremstyle, as the braces are hardwired inside it.

Here is the default for nonumberplain

\newtheoremstyle{nonumberplain}%
  {\item[\theorem@headerfont\hskip\labelsep ##1\theorem@separator]}%
  {\item[\theorem@headerfont\hskip \labelsep ##1\ (##3)\theorem@separator]}

to make it work you will need something like

\makeatletter
\newtheoremstyle{mynonumberplain}%
 {\item[\theorem@headerfont\hskip\labelsep ##1\theorem@separator]}%
 {\item[\theorem@headerfont\hskip \labelsep ##1\ {[##3]}\theorem@separator]}
\makeatother

(since we are already inside a pair of []'s we need to protect it with a pair of {}'s)

For your second question:

\documentclass[a4paper]{memoir}
\usepackage{mathtools}
\newtagform{brackets}{[}{]}
\usetagform{brackets}
\makeatletter
\let\xxx\tagform@
\makeatother
\begin{document}
\xxx{4}
\end{document}

you can use \tagform@ inside the mynonumberplain definition, but it has to come after the \usetagform{brackets}. The xxx is just to get rid of the @

As for the last question

\makeatletter
\newtheoremstyle{mynonumberplain}%
 {\item[\theorem@headerfont\hskip\labelsep ##1\theorem@separator]}%
 {\item[\theorem@headerfont\hskip \labelsep ##1\ {[##3]}\theorem@separator]
 \def\@currentlabel{##3}}
\makeatother

the trick here is that we need the \@currentlabel outside the \item[...], because it forms a local group, and thus would never get outside, unless we make it global, and that might not be a good idea.

share|improve this answer
    
I have added that I use ntheorem. Do you have a suggestion for my other comments? The label and using the brackets as I defined them using mathtools. –  Jonas Teuwen Apr 18 '11 at 8:35
    
@Jonas: was this better? –  daleif Apr 18 '11 at 12:47
    
Yes, I'm thinking about it how I can use your suggestions. About the label I think I need to do something like \def\@currentlabel{#1} where #1 refers to the optional argument. I wonder if I can do that using ntheorem. –  Jonas Teuwen Apr 18 '11 at 13:30
    
@jonas: you can but you need to be a bit devious, see my edit. –  daleif Apr 18 '11 at 22:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.