I am trying to create a command in a style file that I can call inside other commands but its content is to be specified in a normal .tex file that uses this custom document class. Here is my minimum example (created from code I have seen in example documents):
for the .tex file.
The problem is that instead of the .tex file reading the \example{example} as an indication to use this where appropriate in the .cls file, it automatically prints "example" to the PDF file (even though it is not even contained within the document environment - I know this is what is happening from my more complicated codes and also the fact that it still compiles even if I comment out \begin{document}).
Can anybody explain why this code is not working and point me in the direction of a solution (or even a better piece of code with a similar outcome)? Many thanks.
Last edited by Tom_24601 on Wed Dec 28, 2011 1:03 am, edited 1 time in total.
Thank you for your helpful response. The code you suggested works perfectly for my minimum example but in the context of more complicated documents I am having the same problem as before. Here is an extended version of the .cls file in my minimum example to illustrate what I mean:
I have added the \Huge command but when I compile the .tex file it prints at normal size which is what leads me to believe that it is registering the \example{example} part but not the \exampletwo part. It will still compile the code even if I comment out the \begin{document} and \exampletwo lines on the .tex file. I have narrowed the problem down to the
Tom_24601 wrote:The code you suggested works perfectly for my minimum example but in the context of more complicated documents I am having the same problem as before.
I just used your code, which works as expected. If your problem occurs in more complicated code, the cause is there. I cannot help you if you post reduced code, which doesn't have the error. There's nothing to fix.
Tom_24601 wrote:
Here is an extended version of the .cls file in my minimum example to illustrate what I mean
Tom_24601 wrote:
I have added the \Huge command but when I compile the .tex file it prints at normal size
Which .tex file? The above .tex file prints \Huge then.
Just post a combination of cls and tex file which show the error when used together.
I am still having the problem that it is printing at normal size.
Is it possible that there is a package I need to use to make this work, or a particular compiling software (I currently use TexStudio)? I can't see why this would be the case, but I don't understand why these codes would work for you and not for me otherwise.
Can you post your .log file for this example as attachment here, plus the PDF output? If necessary for posting as attachment, rename the file extension.
Tom_24601 wrote:Is it possible that there is a package I need to use to make this work, or a particular compiling software (I currently use TexStudio)?
To make this example work, you don't need a package. Also the editor doesn't matter.
Thank you Stefan, this suggestion was absolutely right - my computer had saved the .cls file in two places and the wrong one was loading; after saving it correctly and deleting the other file the minimum example worked as expected.
I have now exhaustively searched my computer for a similar problem with my original file and cannot find a file that has saved in the wrong directory or anything similar. I have copied my codes into new .cls and .tex files and saved them in place of the other files, and now the code is compiling without any error messages but no PDF file is being produced.
You have convinced me that there is nothing wrong with the code, so are the issues I am currently having still related to LaTeX in which case do you have any more advice for me, or is there generally an issue with my computer which I need to investigate in more detail?
Check the .log file to see which files are actually loaded. Further you can read errors and warnings there, which could explain why there's no PDF file produced. You could post such a .log file here as attachment.