Search code examples
latexbrackets

How to change () to [] in "lem" enviroment TeX?


I have a problem with brackets in enviroment "lem", which is defined in preamble. If you compile my MWE you get: "Lem 1 (Yoneda, 1996)", but I want: "Lem 1 [Yoneda, 1996]". How can I reach this?

I google about this problem, but I didn't find the answer.

\documentclass{article}

%\usepackage[T2A]{fontenc}
%\usepackage[cp1251]{inputenc}
%\usepackage[english]{babel}

\newtheorem{lem}{Lem}

\begin{document}

\begin{lem}[Yoneda, 1996]
Let $F$ be a functor from a locally small category ${\mathcal C}$ to
$\mathbf{Set}$. Then for each object $A$ of $\mathcal{C}$, the
natural transformations $\mathrm{Nat}(h_{A},F) = \mathrm{Hom}
(\mathrm{Hom}(A,-),F)$ from $h_{A}$ to $F$ are in one-to-one
correspondence with the elements of $F(A)$. That is,
$\mathrm{Nat}(h_{A},F) \cong F(A)$. Moreover, this isomorphism is
natural in $A$ and $F$ when both sides are regarded as functors from
${\mathcal{C}} \times \mathbf{Set}^{\mathcal {C}}$ to
$\mathbf{Set}$.
\end{lem}

\end{document}

Solution

  • There are a number of ways to achieve this. One primitive way is to update the internal command setting theorems for which an optional argument is provided - \@opargbegintheorem:

    enter image description here

    \documentclass{article}
    
    \newtheorem{lem}{Lem}
    
    \makeatletter
    \renewcommand{\@opargbegintheorem}[3]{%
      \trivlist
        \item[\hskip\labelsep {\bfseries #1\ #2\ [#3]}]\itshape}% Changed (#3) to [#3]
    \makeatother
    
    \begin{document}
    
    \begin{lem}[Yoneda, 1996]
    Let\/~$F$ be a functor from a locally small category\/~$\mathcal{C}$ to\/~$\mathbf{Set}$. Then for each object\/~$A$ of\/~$\mathcal{C}$, the
    natural transformations\/ $\mathrm{Nat}(h_A, F) = \mathrm{Hom}(\mathrm{Hom}(A, -), F)$ from\/~$h_A$ to\/~$F$ are in one-to-one
    correspondence with the elements of\/~$F(A)$. That is,\/ $\mathrm{Nat}(h_A, F) \cong F(A)$. Moreover, this isomorphism is
    natural in\/~$A$ and\/~$F$ when both sides are regarded as functors from\/~$\mathcal{C} \times \mathbf{Set}^{\mathcal{C}}$ to\/~$\mathbf{Set}$.
    \end{lem}
    
    \end{document}
    

    This will, of course, have a global effect for all theorem-like structures defined via \newtheorem. However, such consistency is often a good thing.

    A more adaptable change is shown here using amsthm (can also be used in conjunction with thmtools).