3

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

ThinkOut (addition). Deep thought ...

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.

5
  • 2
    I don't understand actually. Do you want to have a theorem like environment which accepts [addition]?
    – user31729
    Feb 13, 2017 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, 2017 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, 2017 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, 2017 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, 2017 at 13:53

4 Answers 4

5

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[
headfont=\bfseries,%
notefont=\itshape\mdseries\color{red},
notebraces = {\textup{(}}{\textup{)}},
bodyfont = \mdseries, %
headpunct={.\,—\,}, %
spaceabove=\topsep, %
    spacebelow=\topsep]{Rstyle}

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

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

 \begin{look}[addition]
   Deeper thought.
 \end{look}
\end{document} 

enter image description here

3

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}
\begin{look}[addition]
  Deep thought ...
\end{look}
\end{document}

enter image description here

3

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}

\begin{rem}[addition]
Some text.
\end{rem}

\end{document}

enter image description here

2

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
   .}\quad
  }%
  {\end{trivlist}}

To be used as

\begin{thinkout} ... \end{thinkout}
\begin{thinkout}[optional addendum] ... \end{thinkout}

enter image description here

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

\lipsum[2]
\end{document}
5
  • 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, 2017 at 11:45
  • @egreg Right. It now is \ifx\empty#1.
    – gernot
    Feb 17, 2017 at 11:47
  • Add also \relax after #1, one never knows…
    – egreg
    Feb 17, 2017 at 11:49
  • @egreg I changed it now to the detokenize version, to promote the more robust test for emptiness, though it is more cryptic.
    – gernot
    Feb 17, 2017 at 11:57
  • 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, 2017 at 14:00

You must log in to answer this question.