Hi,
to compile my thesis, I had to move my settings for the fancy header into a separate file (command.tex). So I copied all the corresponding tex in this file like this:
and the document compiled without problems. Take your document and go commenting out parts of it until your document compiles, this will give you a hint as to where the culprit is to be found.
Once the problematic part has been detected, perhaps you can correct the problem yourself, if not, please post a complete and minimal version of your document allowing us to reproduce the problem mentioned.
Ok, I did the check and if I comment out the \markboth{#1}{} and \markright{\thesection\ #1} or I substitute #1 with {} that works.
Here it is my code, in a shortened form.
mainfile.tex:
you must declare an argument for the \makefancyheader command even if it is empty; so use \makefancyheader{} (with a matching pair of braces) instead of just \makefancyheader
Oh thank you so much! Now it runs, but I still have a problem: the title of the chapter does not appear in the pdf , while if I insert the text of command.tex directly in the mainfile.tex it appears on even pages on the right as requested. What is the trick?
The code which produces the correct output is:
Note that you define the command with one argument and then you are using this argument for both \markboth and \markright, so invoking simply \makefancyheader{} will cause both marks to be empty. Perhaps what you are looking for is something like this:
The number of "#" symbols can be used to nest new commands inside each other. Let's suppose that you have defined \commandone with one mandatory argument and now you want to define \commandtwo with one mandatory argument (the number of arguments is not relevant in this example); assume further that inside the definition for \commandtwo you will use the command \commandone previously defined. In the definition of the \commandtwo command, #1 will stand for the mandatory argument of \commandtwo, so how can you refer to the mandatory argument of \commandone? Obviously you cannot use #1 (since, as I already mentioned, #1 represents the mandatory argument of \commandtwo); the TeX solution is simply to double the "#" symbol; with this convention, when you are defining \commandtwo, #1 will represent its own mandatory argument, whereas ##1 will represent the mandatory argument for \commandone.