0

I tried to use \newcommand{\faculty}[1]{\gdef\@faculty{#1}} to have others use my template for thesis and just change text in the brackets \faculty{Fakulta strojní} and it changes every faculty name in the document, e.g. in titlepage. It does work until I add more commands, like \department etc. Then it tells me Use of \@ doesn't match its definition. and shows Faculty without F. I am using subfiles package and preamble.tex.

\begin{titlepage}
    \centering
        \large\textsc{{VŠB - Technická univerzita Ostrava\\
        \@faculty\\
        \@department}}
    \vfill

    {\LARGE{\sffamily{\textbf{Název práce}\\
    Title name}}}\\

    \vfill
    \normalsize{
    \begin{tabularx}{.8\textwidth}{XX}
    Autor: & autor\\
    Vedoucí disertační práce: & director
\end{tabularx}\\
    \vspace{2em}
Ostrava~2021}\

\end{titlepage}

\documentclass[a4paper, 12pt]{scrartcl}
\input{nastaveni/preamble}
\usepackage{xr}
\usepackage{subfiles}
    \externaldocument[M-]{\subfix{main}}
\usepackage{graphicx}

\faculty{Fakulta strojní}
\department{Katedra energetiky}

\begin{document}

enter image description here

1 Answers1

2

You are using commands that involve @ which is a reserved character for use within class and package files. Since you are using \input to input the commands instead of putting them into a proper package, then you need to wrap the \input command with \makeatletter and \makeatother.

\documentclass[a4paper, 12pt]{scrartcl}
\makeatletter
\input{nastaveni/preamble}
\makeatother
\usepackage{xr}
\usepackage{subfiles}
    \externaldocument[M-]{\subfix{main}}
\usepackage{graphicx}

\faculty{Fakulta strojní} \department{Katedra energetiky}

\begin{document}

See the following questions for more details:

Alan Munn
  • 218,180
  • When I added that it changed to this: it prints faculty and department but not Fakulta strojní and Katedra energetiky as it was meant. – Jan Opletal Dec 16 '20 at 19:33
  • @JanOpletal: Did you place the \makeatletter...\makeatother pair outside of the titlepage environment, or inside? – Werner Dec 16 '20 at 19:35
  • Thank you, I made a mistake when using titlepage as subfile and not printing by \maketitle, and defining titlepage in preamble. Now it works :) – Jan Opletal Dec 16 '20 at 19:45