# Environment with a dummy parameter

This couple of commands

\def\look{\@ifnextchar[{\@lookY}{\par\noindent{\textsf{ThinkOut. }}}}
\def\@lookY[#1]{\par\noindent\textsf{ThinkOut (\textit{#1}).}}


provides a utility with an effect

\look Deep thought ...


gives

ThinkOut. Deep thought ...

and

\look[addition] Deep thought ...

gives

I would like to organize the commands above into an environment but without usage of amsmath.sty + ntheorem.sty utilities. This is because usage of the scheme

\newtheoremstyle{Rstyle}{}{}{\itshape}{2em}{\sffamily}{.}{}{}
\theoremstyle{Rstyle}
\newtheorem{rem}{ThinkOut}
\newtheorem*{rem*}{ThinkOut}


does not allow me to emphasize the [addition] dummy argument in \begin{rem}[addition] ... \end{rem} independently of the title "ThinkOut". Is it possible to solve the problem by means of the ams-internal utilities above or needs to create my own command? Formatting the [addition] argument (if it has been called) is described in the second of commands above \@lookY.

• I don't understand actually. Do you want to have a theorem like environment which accepts [addition]? – user31729 Feb 13 '17 at 13:05
• Yes, this is a theorem like environment but with an independent possibility to format its [addition] argument when it has been typed. – user40791 Feb 13 '17 at 13:09
• Should be possible with a wrapper environment, please add a compilable document such that we don't have to glue all together! – user31729 Feb 13 '17 at 13:14
• You should take a look at the thmtools package, which cooperates with ntheorem as well as amsthm. It has a notefont key, and makes it easy to define new theorem styles. – Bernard Feb 13 '17 at 13:24
• Apart from notefont key I might have some parenthesises or something other inside/arround the [addition]. It seems to me that one to create a simple and new command would be easier. No ...? – user40791 Feb 13 '17 at 13:53

Here is an example of what can be done with thmtools. If you want an easy independent formatting of the optional argument, you have to use amsthm, as all keys for the optional argument (notefont, &c.) do not work with ntheorem (you can define a new ntheorem style, but it's not so easy as with thmtools).

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{thmtools}

\declaretheoremstyle[
notefont=\itshape\mdseries\color{red},
notebraces = {\textup{(}}{\textup{)}},
bodyfont = \mdseries, %
spaceabove=\topsep, %
spacebelow=\topsep]{Rstyle}

\declaretheorem[name=ThinkOut, numbered=no,style=Rstyle]{look}

\begin{document}
\begin{look}
Deep thought.
\end{look}

Deeper thought.
\end{look}
\end{document}


You can certainly use amsthm; the only problem is using the right specification for the header.

\documentclass{article}
\usepackage{amsthm}

\makeatletter
\newtheoremstyle{Rstyle}
{}
{}
{\itshape}
{2em}
{\sffamily}
{.}
{ }
{\thmname{#1} \thmnumber{#2}\@ifnotempty{#3}{ (\textsl{#3})}}
\makeatother
\theoremstyle{Rstyle}
\newtheorem{rem}{ThinkOut}
\newtheorem*{rem*}{ThinkOut}

\begin{document}

\begin{rem}
Some text.
\end{rem}

Some text.
\end{rem}

\end{document}


A version using LaTeX theorem.

\documentclass{article}
\newtheorem{lookthm}{ThinkOut}
\newenvironment{look}[1][\empty]{\begin{lookthm}%
\ifx#1\empty\else\textit{(#1)}\fi%
}{\end{lookthm}}
\begin{document}
\begin{look}
Deep thought ...
\end{look}
Deep thought ...
\end{look}
\end{document}


As long as you don't need numbering and referencing, you can define an environment with an optional argument using plain LaTeX.

\newenvironment{thinkout}[1][]%
{\begin{trivlist}
\item[]%
{\bfseries ThinkOut%
\if\relax\detokenize{#1}\relax\else\ (#1)\fi
}%
{\end{trivlist}}


To be used as

\begin{thinkout} ... \end{thinkout}


\documentclass{article}
\newenvironment{thinkout}[1][]%
{\begin{trivlist}
\item[]%
{\bfseries ThinkOut%
\if\relax\detokenize{#1}\relax\else\ (#1)\fi
}%
{\end{trivlist}}
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\begin{thinkout}
Deep thought \dots
\end{thinkout}
\lipsum[2]

• Wrong. It should be \ifx\empty#1. But it's better to leave empty the default argument and make the test to be \if\relax\detokenize{#1}\relax. – egreg Feb 17 '17 at 11:45
• @egreg Right. It now is \ifx\empty#1. – gernot Feb 17 '17 at 11:47
• Add also \relax after #1, one never knows… – egreg Feb 17 '17 at 11:49
• Thanks. Waiting for a \begin{list}... version because there is no possibility to adjust vertical spaces before/after/left/right text in the \begin{trivlist}... version. – user40791 Feb 17 '17 at 14:00