I am writing a template for a poster (using beamer/beamerposter) package for students that I intend to distribute as a folder. It will contain a .tex file that the students can start editing, and a style file, which is a custom beamer theme, that I do not want them to mess with.

The theme is already designed to look nice with one user-specified color, with all other structure and text colors derived from that color using \colorlet{usercolor!10!white} etc. type of mixins.

The thing works as defined above.

The work is nearly done, except for one vexing issue. I want the students to be able to define the user-specified color in the .tex file and not have to ever edit the style file.

So, I tried the following:



I have the following directive in .tex file:


I get a lot undefined control sequence errors in the style file where I am using \@posterX macros.

I guess that this question is more TeX and less color related. How do I force the \def's in the \newcommand definition above to expand immediately?

I apologize for not providing an MWE as there are several files involved, some containing confidential information. In any case, I have a hunch that this problem is largely due to my programming brain failing to come to terms with some TeX peculiarities.

  • Why not just directly define the colour inside \postercolor? (\newcommand{\postercolor}[3]{\definecolor{posterthemecolor}{RGB}{#1,#2,#3}}) Or for that matter, is it that hard for your students to just use \definecolor{posterthemecolor} directly in their tex file? Nov 17 '18 at 10:02
  • Thanks @DavidPurton. However, that does not solve the problem. I get the same error as before, because as I suspect, the \newcommand macro inside the style file is not actually expanded when \postercolor{128}{0}{0} is called from outside. I need something forces the evaluation of the command when it is called inside the theme. As to the other suggestion, that is a) supposes that the students won't mess up the definition, b) does not modularly separate out the elements of the poster (that I expect them to worry about), and elements of TeX (that I do not expect them to worry about). Nov 17 '18 at 16:29
  • In that case we do need a MWE. Condense it to one file (just put relevant things in the preamble). Leave out all your confidential stuff since it is not relevant to the problem. As you have it at the moment in your question the most likely reason for undefined references is because you call \definecolor in the sty file before \postercolor is called in the tex file. My suggestion does work, so something else is going wrong in your file that I can't guess. Nov 17 '18 at 21:50

You don't have to use the \def\@poster* macros at all. Just define the colour inside \postercolor and ensure that it's initialised by your style.



% contents of beamerthemeXXX.sty
% ...
% define theme colour setting macro

% initialise theme colour
% ...
% end of beamerthemeXXX.sty

% user document preamble

% redefine theme colour if necessary


\textcolor{posterthemecolor}{poster colour}

  • Thanks@DavidPurton. Correct me if I am wrong (based on commented out \usepackage in your listing above), but does this not imply simply dumping the contents of the beamertheme.sty file into the main .tex file as a preamble? This would not be a practical possibility because my .sty file has about 500 lines, which I definitely do not want the students to be even accidentally messing up. The .tex file has about ~150 lines. I will try to get you a multi-file MWE as soon as I have time, but this is a package writing problem that cannot be avoided by just making one giant .tex file. Nov 18 '18 at 9:40
  • @user2751530 no, you put it in the style file and uncomment the usepackage line. I’m just showing the two lines you need in the style file and an example that will compile to produce the expected output. Nov 18 '18 at 10:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.