1

I'm trying to store text in a variable like \def\course{Statistics} but I want the text to be relaxed everywhere I execute the command. When I input \def\course{\relax Statistics}, the text is relaxed on the first page however after that it stops being relaxed. Example:

I define these two commands: \def\course {Statistics} \def\assignment{Written Assignment 2}

Then I run \title{\relax\course: \relax\assignment} and the heading is displayed normally like this: enter image description here

but on the 3rd page, it reverts back to this: enter image description here

How can I make sure that this works everywhere?

  • 3
    What do you mean by having the text "relaxed"? – User23456234 Mar 19 '24 at 01:30
  • So essentially, I'm trying to let the text I have defined be formatted by the outside environment (i.e. formatting defined in classes etc.), however, the formatting inside text variable takes precedence, even if I haven't explicitly formatted the text inside the command. – Caleb Aryee Mar 19 '24 at 01:36
  • 3
    I'm not quite following what you said, but I think \relax means something different than what you think it means. \relax means "you can stop looking for arguments to the command you're processing", not "don't worry about the formatting". Regardless, your headings look like they have some special formatting applied to them already. Could you post the minimal 20 lines of code we would need to see the result you're seeing? – Teepeemm Mar 19 '24 at 02:43
  • Welcome! You don't show any formatting inside the variables. \def\course {Statistics} doesn't include any formatting. It is just a string of letters. Also \title{\relax\course: \relax\assignment} isn't responsible for the output you show unless you've redefined \title. The standard \title doesn't produce any typeset output at all. It specifies the title, but it doesn't do anything with that information. \maketitle then produces the title. But what you show looks like a header rather than the title. – cfr Mar 19 '24 at 03:27
  • Although I do not understand exactly what you want to do, I would suggest you use a \course* and \course. If there are more than two versions of course then use keys. – yannisl Mar 19 '24 at 03:32

1 Answers1

0

I can reproduce the problem with the amsart class. You should always specify what document class you're using.

The problem stems from the fact that you're not adding \author and amsart does some weird juggling with the data.

In particular, it sometimes uses \uppercase, notwithstanding AMS people have long been warned about the weakness of this approach. Anyway, you can fix the problem by loading textcase.

\documentclass{amsart}
\usepackage{textcase}

\usepackage{lipsum}% filler text

\def\course{Statistics} \def\assignment{Written Assignment 2}

\begin{document}

\title{\course: \assignment}

\maketitle

\lipsum[1-20]

\end{document}

By the way, \relax isn't doing anything useful where you put it.

Top of page 2

enter image description here

Top of page 3

enter image description here

egreg
  • 1,121,712