Giter Site home page Giter Site logo

ltx-pkg-ntheorem-issues's People

Contributors

muzimuzhi avatar

Watchers

 avatar  avatar

ltx-pkg-ntheorem-issues's Issues

Missing braces in \item[{... #1 ...}]

  • For macros not defined by xparse, one need to use \cmd[{... ] ...}] to reserve ] used in the optional argument.
  • Inside the definition of a macro, if something is parsed as the opt-arg of another macro \cmdB, then \cmdB[{...}] is always recommended. This way, the code works either ... contains ] or not.
  • Otherwise, more than one extra level of braces are required, see https://tex.stackexchange.com/a/17108.

In the example from linked answer,

\documentclass{article}
\usepackage{ntheorem}
\newtheorem{thm}{Theorem}

\begin{document}
\begin{thm}[{\cite[page 10]{ABC2011}}]
\end{thm}

\begin{thebibliography}{9}
  \bibitem{ABC2011} A bibitem.
\end{thebibliography}
\end{document}

the opt-arg of thm env acts as the #3 of \@opargbegintheorem, which is defined as

\gdef\th@plain{%
  \def\theorem@headerfont{\normalfont\bfseries}\itshape%
  \def\@begintheorem##1##2{%
      \item[\hskip\labelsep \theorem@headerfont ##1\ ##2.]}%
  \def\@opargbegintheorem##1##2##3{%
     \item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3).]}}

Here \begin{thm}[{\cite[page 10]{ABC2011}}] will expand to

\item[... \cite[page 10]{ABC2011} ...]

hence raises errors.

Short-term workaround would be:

\documentclass{article}
\usepackage{ntheorem}
\usepackage{regexpatch}

\newtheorem{thm}{Theorem}

\makeatletter
\regexpatchcmd*\th@plain
  {\c{item}\cO\[(.*?\cO)\]}
  {\c{item}\cO\[\cB\{\1\cE\}\cO\]}
  {}{\fail}
\makeatother

\begin{document}

\begin{thm}[{\cite[page 10]{ABC2011}}]
A theorem.
\end{thm}

\begin{thebibliography}{9}
  \bibitem{ABC2011} A bibitem.
\end{thebibliography}

\end{document}

Long-term fix is to use \item[{...}] throughout the ntheorem.sty.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.