I am trying to write a macro (\exhibitTitle) that would behave similar to section/chapter, but with its own counter that increases by 1. Its important that it supports label (doesn't have to be standart \label or \ref).

For example \exhibitTitle{First Exhibit} should output 'First Exhibit + counter number' in bold in the center of line (like \exhibitTitle is defined in the example below).

\ref{exhibit1} (or any other reference macro name) should output integer count that corresponds to label exhibit1. Count should start from 1 and increases by 1 every time \exhibitTitle{...} is used (and only if \exhibitTitle), that is this counter shouldn't be affected by \section.

\exhibitTitle{text} will be in the very end of the document (after all references to Exhibit labels in text).

Basically labels should work in very similar way as with section/chapter. Current \exhibitTitle in code below does automatic numbering, but I don't see how to add label support to it.

Minimal example (doesn't work b/c I don't know how to do this):

Exhibit \arabic{exhibitcounter} \end{Huge} \\ #1
Text text Exhibit \ref{exhibit1}
Text text Exhibit \ref{exhibit2}
\exhibitTitle{First Exhibit} \label{exhibit1}
\exhibitTitle{Second Exhibit} \label{exhibit2}

Thank you

  • 6
    change \stepcounter to \refstepcounter and then \label will work (and add % to ends of lines in the definition) – David Carlisle Oct 4 at 6:54
  • @DavidCarlisle You did not commented on Huge as an environment. I thought we were supposed to say \Huge instead. – Denis Oct 4 at 8:31
  • 3
    @Denis it's usually good style to do so (and it only works correctly here due to the trailing \\ which are normally to be avoided, but by design in latex any declaration can be used as an environment. (the latex book gives the example of using \begin{em} instead of \em for example) – David Carlisle Oct 4 at 8:36
  • @DavidCarlisle Quite clarifying. Thanks! – Denis Oct 4 at 8:56
  • 1
    normally better to use \Huge, but \begin{Huge}...\end{Huge} is the same as {\Huge...} so normally (in either case) you need a blank line at the end of ... but here it is in the scope of \centering which makes \\ be \par so equivalent to a blank line so the trailing \\ is enough. – David Carlisle Oct 5 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.