1

I have a theorem-style defined like this (based on this answer https://tex.stackexchange.com/a/65955/228413):

\newtheoremstyle{note}% name
    {10pt}%             space above
    {10pt}%             space below
    {}%                 body font
    {}%                 indent amount
    {}%                 theorem head font
    {}%                 punctuation after theorem head
    {\newline}%         space after theorem head
    {\underline{\thmname{\@ifempty{#3}{#1}\@ifnotempty{#3}{#3}}}} % theorem head spec

....

\theoremstyle{note} \newtheorem*{note}{Notiz}

And when using this environment in a subfile it produces the correct result when compiled by itself:

\begin{note}[Title]
    \lipsum[4][1-3]
\end{note}

title getting displayed correctly as "Title"

But when the same file is included (\subfile{file_name}), the result looks like this:

title getting displayed as "ifemptyTitleNotizifnotemptyTitleTitle"

What is causing this, and how can I fix it?

Thanks in advance!

1 Answers1

1

You have to enclose the \newtheoremstyle definition between \makeatletter and \makeatother.

\makeatletter % <<<<<<<<<<<<<<<<<< HERE <<<<<<<<<<<<<<
\newtheoremstyle{note}% name
    {10pt}%             space above
    {10pt}%             space below
    {}%                 body font
    {}%                 indent amount
    {}%                 theorem head font
    {}%                 punctuation after theorem head
    {\newline}%         space after theorem head
    {\underline{\thmname{\@ifempty{#3}{#1}\@ifnotempty{#3}{#3}}}} % theorem head spec
\makeatother % <<<<<<<<<<<<<<<<<< HERE <<<<<<<<<<<<<<

Your problem is not related to the subiles package. (Well, it is surprising that it works at all when compiling the subfile.) Check out the source where you copied the code from. There you will also find these two extra commands.

gernot
  • 49,614
  • Thank you! Do I have to do this for all \newtheormstyle? – Kyuhunter Apr 26 '21 at 12:35
  • 1
    You have to do it whenever the character "@" ("at" symbol) appears in a command name. In a sty and cls file, this character counts as a letter, but on user level it does not. \makeatletter makes "at" a letter, and \makeatother makes "at" again a character of category "other", as it should be on user level. See also https://tex.stackexchange.com/q/6240 – gernot Apr 26 '21 at 17:11