Defined command only works in preamble
up vote
2
down vote
favorite
I'm writing a class, and when using it I want to use small caps with a font that doesn't have small caps defined (I know – not as good as the real thing). I found this answer Fake small caps with XeTeX/fontspec? which I tried to include, however I get the errors:
Missing $ inserted.
Missing $ inserted.
You can't use 'spacefactor' in vertical mode.
However, the code works perfectly when it's pasted into the preamble.
Anyone know what's going on?
MWE
Class File
ProvidesClass{custom}[a custom class]
NeedsTeXFormat{LaTeX2e}
DeclareOption*{
PassOptionsToClass{CurrentOption}{scrreprt}
}
ProcessOptionsrelax
LoadClass[usegeometry]{scrreprt}
RequirePackage{graphicx}
RequirePackage{plex-serif}
% Small Caps
makeatletter
newlengthfake@f
newlengthfake@c
deffakesc#1{%
begingroup%
xdeffake@name{csnamecurr@fontshape/f@sizeendcsname}%
fontsize{fontdimen8fake@name}{baselineskip}selectfont%
uppercase{#1}%
endgroup%
}
makeatother
newcommandfauxsc[1]{fauxschelper#1 relaxrelax}
deffauxschelper#1 #2relax{%
fauxschelphelp#1relaxrelax%
ifrelax#2relaxelse fauxschelper#2relaxfi%
}
defHscale{.83}defVscale{.72}defCscale{1.00}
deffauxschelphelp#1#2relax{%
ifnum`#1>``ifnum`#1<`{scalebox{Hscale}[Vscale]{uppercase{#1}}else%
scalebox{Cscale}[1]{#1}fielsescalebox{Cscale}[1]{#1}fi%
ifxrelax#2relaxelsefauxschelphelp#2relaxfi}
makeatletter
newcommand{maketitleee}{
fauxsc{@title}
}
makeatother
Document
documentclass[a4paper, 12pt, oneside]{custom}
title{Title}
author{Author}
begin{document}
maketitleee
end{document}
Update
Removing all the makeatletter
s and makeatother
s seems to change the errors given to those below
Update 2
This was fixed by @moewe's suggestion, which is replacing fauxsc{@title}
with expandafterfauxscexpandafter{@title}
macros errors documentclass-writing
|
show 12 more comments
up vote
2
down vote
favorite
I'm writing a class, and when using it I want to use small caps with a font that doesn't have small caps defined (I know – not as good as the real thing). I found this answer Fake small caps with XeTeX/fontspec? which I tried to include, however I get the errors:
Missing $ inserted.
Missing $ inserted.
You can't use 'spacefactor' in vertical mode.
However, the code works perfectly when it's pasted into the preamble.
Anyone know what's going on?
MWE
Class File
ProvidesClass{custom}[a custom class]
NeedsTeXFormat{LaTeX2e}
DeclareOption*{
PassOptionsToClass{CurrentOption}{scrreprt}
}
ProcessOptionsrelax
LoadClass[usegeometry]{scrreprt}
RequirePackage{graphicx}
RequirePackage{plex-serif}
% Small Caps
makeatletter
newlengthfake@f
newlengthfake@c
deffakesc#1{%
begingroup%
xdeffake@name{csnamecurr@fontshape/f@sizeendcsname}%
fontsize{fontdimen8fake@name}{baselineskip}selectfont%
uppercase{#1}%
endgroup%
}
makeatother
newcommandfauxsc[1]{fauxschelper#1 relaxrelax}
deffauxschelper#1 #2relax{%
fauxschelphelp#1relaxrelax%
ifrelax#2relaxelse fauxschelper#2relaxfi%
}
defHscale{.83}defVscale{.72}defCscale{1.00}
deffauxschelphelp#1#2relax{%
ifnum`#1>``ifnum`#1<`{scalebox{Hscale}[Vscale]{uppercase{#1}}else%
scalebox{Cscale}[1]{#1}fielsescalebox{Cscale}[1]{#1}fi%
ifxrelax#2relaxelsefauxschelphelp#2relaxfi}
makeatletter
newcommand{maketitleee}{
fauxsc{@title}
}
makeatother
Document
documentclass[a4paper, 12pt, oneside]{custom}
title{Title}
author{Author}
begin{document}
maketitleee
end{document}
Update
Removing all the makeatletter
s and makeatother
s seems to change the errors given to those below
Update 2
This was fixed by @moewe's suggestion, which is replacing fauxsc{@title}
with expandafterfauxscexpandafter{@title}
macros errors documentclass-writing
2
Welcome to TeX.SX! Without seeing your code it is impossible to say what the problem is. Can you please add a minimal working example. A MWE should start with adocumentclass
command, have a minimal preamble and thenbegin{document}...end{document}
. The code should compile and be as small as possible to demonstrate your problem. Cutting your code down to a MWE may well reveal what your problem actually is. In any case, it is really difficult to help you without more information.
– Andrew
yesterday
4
please don't just post disconnected code fragments, post a single small example that we can run to get the error that you are asking about, otherwise it's very hard to guess the error and advise how to fix it.
– David Carlisle
yesterday
1
As David says, please post a full minimal working example: the code should be as small as possible so as to reproduce your error. You should either post a minimal latex document that exhibits the problem or, alternatively, a minimal class file together with a minimal latex document. The key thing is that we should be able to reproduce your error from the code that you post. It is virtually impossible to help you if you don't show us the problem.
– Andrew
yesterday
1
your definition ofmaketitleee
should have themakeatletter/makeatother
outside, not inside. There might be other problems (code looks complicated).
– jfbu
yesterday
1
There still is amakeatletter
and amakeatother
in your.cls
file. Remove allmakeatletter
s andmakeatother
s from the.cls
. As I said before if I remove all of them (in the earlier version two pairs, now only one pair), the MWE compiles.
– moewe
yesterday
|
show 12 more comments
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm writing a class, and when using it I want to use small caps with a font that doesn't have small caps defined (I know – not as good as the real thing). I found this answer Fake small caps with XeTeX/fontspec? which I tried to include, however I get the errors:
Missing $ inserted.
Missing $ inserted.
You can't use 'spacefactor' in vertical mode.
However, the code works perfectly when it's pasted into the preamble.
Anyone know what's going on?
MWE
Class File
ProvidesClass{custom}[a custom class]
NeedsTeXFormat{LaTeX2e}
DeclareOption*{
PassOptionsToClass{CurrentOption}{scrreprt}
}
ProcessOptionsrelax
LoadClass[usegeometry]{scrreprt}
RequirePackage{graphicx}
RequirePackage{plex-serif}
% Small Caps
makeatletter
newlengthfake@f
newlengthfake@c
deffakesc#1{%
begingroup%
xdeffake@name{csnamecurr@fontshape/f@sizeendcsname}%
fontsize{fontdimen8fake@name}{baselineskip}selectfont%
uppercase{#1}%
endgroup%
}
makeatother
newcommandfauxsc[1]{fauxschelper#1 relaxrelax}
deffauxschelper#1 #2relax{%
fauxschelphelp#1relaxrelax%
ifrelax#2relaxelse fauxschelper#2relaxfi%
}
defHscale{.83}defVscale{.72}defCscale{1.00}
deffauxschelphelp#1#2relax{%
ifnum`#1>``ifnum`#1<`{scalebox{Hscale}[Vscale]{uppercase{#1}}else%
scalebox{Cscale}[1]{#1}fielsescalebox{Cscale}[1]{#1}fi%
ifxrelax#2relaxelsefauxschelphelp#2relaxfi}
makeatletter
newcommand{maketitleee}{
fauxsc{@title}
}
makeatother
Document
documentclass[a4paper, 12pt, oneside]{custom}
title{Title}
author{Author}
begin{document}
maketitleee
end{document}
Update
Removing all the makeatletter
s and makeatother
s seems to change the errors given to those below
Update 2
This was fixed by @moewe's suggestion, which is replacing fauxsc{@title}
with expandafterfauxscexpandafter{@title}
macros errors documentclass-writing
I'm writing a class, and when using it I want to use small caps with a font that doesn't have small caps defined (I know – not as good as the real thing). I found this answer Fake small caps with XeTeX/fontspec? which I tried to include, however I get the errors:
Missing $ inserted.
Missing $ inserted.
You can't use 'spacefactor' in vertical mode.
However, the code works perfectly when it's pasted into the preamble.
Anyone know what's going on?
MWE
Class File
ProvidesClass{custom}[a custom class]
NeedsTeXFormat{LaTeX2e}
DeclareOption*{
PassOptionsToClass{CurrentOption}{scrreprt}
}
ProcessOptionsrelax
LoadClass[usegeometry]{scrreprt}
RequirePackage{graphicx}
RequirePackage{plex-serif}
% Small Caps
makeatletter
newlengthfake@f
newlengthfake@c
deffakesc#1{%
begingroup%
xdeffake@name{csnamecurr@fontshape/f@sizeendcsname}%
fontsize{fontdimen8fake@name}{baselineskip}selectfont%
uppercase{#1}%
endgroup%
}
makeatother
newcommandfauxsc[1]{fauxschelper#1 relaxrelax}
deffauxschelper#1 #2relax{%
fauxschelphelp#1relaxrelax%
ifrelax#2relaxelse fauxschelper#2relaxfi%
}
defHscale{.83}defVscale{.72}defCscale{1.00}
deffauxschelphelp#1#2relax{%
ifnum`#1>``ifnum`#1<`{scalebox{Hscale}[Vscale]{uppercase{#1}}else%
scalebox{Cscale}[1]{#1}fielsescalebox{Cscale}[1]{#1}fi%
ifxrelax#2relaxelsefauxschelphelp#2relaxfi}
makeatletter
newcommand{maketitleee}{
fauxsc{@title}
}
makeatother
Document
documentclass[a4paper, 12pt, oneside]{custom}
title{Title}
author{Author}
begin{document}
maketitleee
end{document}
Update
Removing all the makeatletter
s and makeatother
s seems to change the errors given to those below
Update 2
This was fixed by @moewe's suggestion, which is replacing fauxsc{@title}
with expandafterfauxscexpandafter{@title}
macros errors documentclass-writing
macros errors documentclass-writing
edited 22 hours ago
asked yesterday
tecosaur
1578
1578
2
Welcome to TeX.SX! Without seeing your code it is impossible to say what the problem is. Can you please add a minimal working example. A MWE should start with adocumentclass
command, have a minimal preamble and thenbegin{document}...end{document}
. The code should compile and be as small as possible to demonstrate your problem. Cutting your code down to a MWE may well reveal what your problem actually is. In any case, it is really difficult to help you without more information.
– Andrew
yesterday
4
please don't just post disconnected code fragments, post a single small example that we can run to get the error that you are asking about, otherwise it's very hard to guess the error and advise how to fix it.
– David Carlisle
yesterday
1
As David says, please post a full minimal working example: the code should be as small as possible so as to reproduce your error. You should either post a minimal latex document that exhibits the problem or, alternatively, a minimal class file together with a minimal latex document. The key thing is that we should be able to reproduce your error from the code that you post. It is virtually impossible to help you if you don't show us the problem.
– Andrew
yesterday
1
your definition ofmaketitleee
should have themakeatletter/makeatother
outside, not inside. There might be other problems (code looks complicated).
– jfbu
yesterday
1
There still is amakeatletter
and amakeatother
in your.cls
file. Remove allmakeatletter
s andmakeatother
s from the.cls
. As I said before if I remove all of them (in the earlier version two pairs, now only one pair), the MWE compiles.
– moewe
yesterday
|
show 12 more comments
2
Welcome to TeX.SX! Without seeing your code it is impossible to say what the problem is. Can you please add a minimal working example. A MWE should start with adocumentclass
command, have a minimal preamble and thenbegin{document}...end{document}
. The code should compile and be as small as possible to demonstrate your problem. Cutting your code down to a MWE may well reveal what your problem actually is. In any case, it is really difficult to help you without more information.
– Andrew
yesterday
4
please don't just post disconnected code fragments, post a single small example that we can run to get the error that you are asking about, otherwise it's very hard to guess the error and advise how to fix it.
– David Carlisle
yesterday
1
As David says, please post a full minimal working example: the code should be as small as possible so as to reproduce your error. You should either post a minimal latex document that exhibits the problem or, alternatively, a minimal class file together with a minimal latex document. The key thing is that we should be able to reproduce your error from the code that you post. It is virtually impossible to help you if you don't show us the problem.
– Andrew
yesterday
1
your definition ofmaketitleee
should have themakeatletter/makeatother
outside, not inside. There might be other problems (code looks complicated).
– jfbu
yesterday
1
There still is amakeatletter
and amakeatother
in your.cls
file. Remove allmakeatletter
s andmakeatother
s from the.cls
. As I said before if I remove all of them (in the earlier version two pairs, now only one pair), the MWE compiles.
– moewe
yesterday
2
2
Welcome to TeX.SX! Without seeing your code it is impossible to say what the problem is. Can you please add a minimal working example. A MWE should start with a
documentclass
command, have a minimal preamble and then begin{document}...end{document}
. The code should compile and be as small as possible to demonstrate your problem. Cutting your code down to a MWE may well reveal what your problem actually is. In any case, it is really difficult to help you without more information.– Andrew
yesterday
Welcome to TeX.SX! Without seeing your code it is impossible to say what the problem is. Can you please add a minimal working example. A MWE should start with a
documentclass
command, have a minimal preamble and then begin{document}...end{document}
. The code should compile and be as small as possible to demonstrate your problem. Cutting your code down to a MWE may well reveal what your problem actually is. In any case, it is really difficult to help you without more information.– Andrew
yesterday
4
4
please don't just post disconnected code fragments, post a single small example that we can run to get the error that you are asking about, otherwise it's very hard to guess the error and advise how to fix it.
– David Carlisle
yesterday
please don't just post disconnected code fragments, post a single small example that we can run to get the error that you are asking about, otherwise it's very hard to guess the error and advise how to fix it.
– David Carlisle
yesterday
1
1
As David says, please post a full minimal working example: the code should be as small as possible so as to reproduce your error. You should either post a minimal latex document that exhibits the problem or, alternatively, a minimal class file together with a minimal latex document. The key thing is that we should be able to reproduce your error from the code that you post. It is virtually impossible to help you if you don't show us the problem.
– Andrew
yesterday
As David says, please post a full minimal working example: the code should be as small as possible so as to reproduce your error. You should either post a minimal latex document that exhibits the problem or, alternatively, a minimal class file together with a minimal latex document. The key thing is that we should be able to reproduce your error from the code that you post. It is virtually impossible to help you if you don't show us the problem.
– Andrew
yesterday
1
1
your definition of
maketitleee
should have the makeatletter/makeatother
outside, not inside. There might be other problems (code looks complicated).– jfbu
yesterday
your definition of
maketitleee
should have the makeatletter/makeatother
outside, not inside. There might be other problems (code looks complicated).– jfbu
yesterday
1
1
There still is a
makeatletter
and a makeatother
in your .cls
file. Remove all makeatletter
s and makeatother
s from the .cls
. As I said before if I remove all of them (in the earlier version two pairs, now only one pair), the MWE compiles.– moewe
yesterday
There still is a
makeatletter
and a makeatother
in your .cls
file. Remove all makeatletter
s and makeatother
s from the .cls
. As I said before if I remove all of them (in the earlier version two pairs, now only one pair), the MWE compiles.– moewe
yesterday
|
show 12 more comments
1 Answer
1
active
oldest
votes
up vote
5
down vote
accepted
First and foremost: faking small caps for a font that hasn't them is hopeless.
When LaTeX is reading a .cls
file, makeatletter
is implicitly in force and issuing makeatother
will most likely introduce problems.
Indeed it does, because when we arrive at defining maketitlee
, @
is an “other character”, so the definition becomes
• •makeatletter•@•t•i•t•l•e•makeatother•
(•
is used to separate tokens). Note that when maketitlee
is called, the replacement text has already been tokenized, so makeatletter
will do nothing at all.
Never use makeatletter
and makeatother
in a .cls
file except in the body of a macro definition that has among its actions inputting a file where the special treatment of @
is needed. This is not the case of your maketitlee
macro.
After removing makeatletter
and makeatother
everywhere in the class file, compiling your example .tex
file produces no error and the output is
that clearly shows what I mean in the top line of this answer.
I see, however — if I remove themakeatletter
andmakeatother
it doesn't work.
– tecosaur
yesterday
@tecosaur I tried, of course.
– egreg
yesterday
Something that may throw a spanner in the works, after seeing this comment tex.stackexchange.com/questions/459738/… I realised I needed to modify the MWE given, for me that MWE doesn't successfully compile.
– tecosaur
23 hours ago
However, this does solve the issue which I had (at least the first one). Thanks :)
– tecosaur
22 hours ago
3
In some situations better thanmakeatletter..makeatother
is:begingroupmakeatletter@firstofone{endgroup <Stuff where @ must be letter>}
. This way the category code of@
will be reset to whatever it was before issuing themakeatletter
-command.makeatother
does set the category code of@
to 12 (other) no matter what it was before.
– Ulrich Diez
21 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
First and foremost: faking small caps for a font that hasn't them is hopeless.
When LaTeX is reading a .cls
file, makeatletter
is implicitly in force and issuing makeatother
will most likely introduce problems.
Indeed it does, because when we arrive at defining maketitlee
, @
is an “other character”, so the definition becomes
• •makeatletter•@•t•i•t•l•e•makeatother•
(•
is used to separate tokens). Note that when maketitlee
is called, the replacement text has already been tokenized, so makeatletter
will do nothing at all.
Never use makeatletter
and makeatother
in a .cls
file except in the body of a macro definition that has among its actions inputting a file where the special treatment of @
is needed. This is not the case of your maketitlee
macro.
After removing makeatletter
and makeatother
everywhere in the class file, compiling your example .tex
file produces no error and the output is
that clearly shows what I mean in the top line of this answer.
I see, however — if I remove themakeatletter
andmakeatother
it doesn't work.
– tecosaur
yesterday
@tecosaur I tried, of course.
– egreg
yesterday
Something that may throw a spanner in the works, after seeing this comment tex.stackexchange.com/questions/459738/… I realised I needed to modify the MWE given, for me that MWE doesn't successfully compile.
– tecosaur
23 hours ago
However, this does solve the issue which I had (at least the first one). Thanks :)
– tecosaur
22 hours ago
3
In some situations better thanmakeatletter..makeatother
is:begingroupmakeatletter@firstofone{endgroup <Stuff where @ must be letter>}
. This way the category code of@
will be reset to whatever it was before issuing themakeatletter
-command.makeatother
does set the category code of@
to 12 (other) no matter what it was before.
– Ulrich Diez
21 hours ago
add a comment |
up vote
5
down vote
accepted
First and foremost: faking small caps for a font that hasn't them is hopeless.
When LaTeX is reading a .cls
file, makeatletter
is implicitly in force and issuing makeatother
will most likely introduce problems.
Indeed it does, because when we arrive at defining maketitlee
, @
is an “other character”, so the definition becomes
• •makeatletter•@•t•i•t•l•e•makeatother•
(•
is used to separate tokens). Note that when maketitlee
is called, the replacement text has already been tokenized, so makeatletter
will do nothing at all.
Never use makeatletter
and makeatother
in a .cls
file except in the body of a macro definition that has among its actions inputting a file where the special treatment of @
is needed. This is not the case of your maketitlee
macro.
After removing makeatletter
and makeatother
everywhere in the class file, compiling your example .tex
file produces no error and the output is
that clearly shows what I mean in the top line of this answer.
I see, however — if I remove themakeatletter
andmakeatother
it doesn't work.
– tecosaur
yesterday
@tecosaur I tried, of course.
– egreg
yesterday
Something that may throw a spanner in the works, after seeing this comment tex.stackexchange.com/questions/459738/… I realised I needed to modify the MWE given, for me that MWE doesn't successfully compile.
– tecosaur
23 hours ago
However, this does solve the issue which I had (at least the first one). Thanks :)
– tecosaur
22 hours ago
3
In some situations better thanmakeatletter..makeatother
is:begingroupmakeatletter@firstofone{endgroup <Stuff where @ must be letter>}
. This way the category code of@
will be reset to whatever it was before issuing themakeatletter
-command.makeatother
does set the category code of@
to 12 (other) no matter what it was before.
– Ulrich Diez
21 hours ago
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
First and foremost: faking small caps for a font that hasn't them is hopeless.
When LaTeX is reading a .cls
file, makeatletter
is implicitly in force and issuing makeatother
will most likely introduce problems.
Indeed it does, because when we arrive at defining maketitlee
, @
is an “other character”, so the definition becomes
• •makeatletter•@•t•i•t•l•e•makeatother•
(•
is used to separate tokens). Note that when maketitlee
is called, the replacement text has already been tokenized, so makeatletter
will do nothing at all.
Never use makeatletter
and makeatother
in a .cls
file except in the body of a macro definition that has among its actions inputting a file where the special treatment of @
is needed. This is not the case of your maketitlee
macro.
After removing makeatletter
and makeatother
everywhere in the class file, compiling your example .tex
file produces no error and the output is
that clearly shows what I mean in the top line of this answer.
First and foremost: faking small caps for a font that hasn't them is hopeless.
When LaTeX is reading a .cls
file, makeatletter
is implicitly in force and issuing makeatother
will most likely introduce problems.
Indeed it does, because when we arrive at defining maketitlee
, @
is an “other character”, so the definition becomes
• •makeatletter•@•t•i•t•l•e•makeatother•
(•
is used to separate tokens). Note that when maketitlee
is called, the replacement text has already been tokenized, so makeatletter
will do nothing at all.
Never use makeatletter
and makeatother
in a .cls
file except in the body of a macro definition that has among its actions inputting a file where the special treatment of @
is needed. This is not the case of your maketitlee
macro.
After removing makeatletter
and makeatother
everywhere in the class file, compiling your example .tex
file produces no error and the output is
that clearly shows what I mean in the top line of this answer.
edited yesterday
answered yesterday
egreg
697k8518503115
697k8518503115
I see, however — if I remove themakeatletter
andmakeatother
it doesn't work.
– tecosaur
yesterday
@tecosaur I tried, of course.
– egreg
yesterday
Something that may throw a spanner in the works, after seeing this comment tex.stackexchange.com/questions/459738/… I realised I needed to modify the MWE given, for me that MWE doesn't successfully compile.
– tecosaur
23 hours ago
However, this does solve the issue which I had (at least the first one). Thanks :)
– tecosaur
22 hours ago
3
In some situations better thanmakeatletter..makeatother
is:begingroupmakeatletter@firstofone{endgroup <Stuff where @ must be letter>}
. This way the category code of@
will be reset to whatever it was before issuing themakeatletter
-command.makeatother
does set the category code of@
to 12 (other) no matter what it was before.
– Ulrich Diez
21 hours ago
add a comment |
I see, however — if I remove themakeatletter
andmakeatother
it doesn't work.
– tecosaur
yesterday
@tecosaur I tried, of course.
– egreg
yesterday
Something that may throw a spanner in the works, after seeing this comment tex.stackexchange.com/questions/459738/… I realised I needed to modify the MWE given, for me that MWE doesn't successfully compile.
– tecosaur
23 hours ago
However, this does solve the issue which I had (at least the first one). Thanks :)
– tecosaur
22 hours ago
3
In some situations better thanmakeatletter..makeatother
is:begingroupmakeatletter@firstofone{endgroup <Stuff where @ must be letter>}
. This way the category code of@
will be reset to whatever it was before issuing themakeatletter
-command.makeatother
does set the category code of@
to 12 (other) no matter what it was before.
– Ulrich Diez
21 hours ago
I see, however — if I remove the
makeatletter
and makeatother
it doesn't work.– tecosaur
yesterday
I see, however — if I remove the
makeatletter
and makeatother
it doesn't work.– tecosaur
yesterday
@tecosaur I tried, of course.
– egreg
yesterday
@tecosaur I tried, of course.
– egreg
yesterday
Something that may throw a spanner in the works, after seeing this comment tex.stackexchange.com/questions/459738/… I realised I needed to modify the MWE given, for me that MWE doesn't successfully compile.
– tecosaur
23 hours ago
Something that may throw a spanner in the works, after seeing this comment tex.stackexchange.com/questions/459738/… I realised I needed to modify the MWE given, for me that MWE doesn't successfully compile.
– tecosaur
23 hours ago
However, this does solve the issue which I had (at least the first one). Thanks :)
– tecosaur
22 hours ago
However, this does solve the issue which I had (at least the first one). Thanks :)
– tecosaur
22 hours ago
3
3
In some situations better than
makeatletter..makeatother
is: begingroupmakeatletter@firstofone{endgroup <Stuff where @ must be letter>}
. This way the category code of @
will be reset to whatever it was before issuing the makeatletter
-command. makeatother
does set the category code of @
to 12 (other) no matter what it was before.– Ulrich Diez
21 hours ago
In some situations better than
makeatletter..makeatother
is: begingroupmakeatletter@firstofone{endgroup <Stuff where @ must be letter>}
. This way the category code of @
will be reset to whatever it was before issuing the makeatletter
-command. makeatother
does set the category code of @
to 12 (other) no matter what it was before.– Ulrich Diez
21 hours ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459738%2fdefined-command-only-works-in-preamble%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
Welcome to TeX.SX! Without seeing your code it is impossible to say what the problem is. Can you please add a minimal working example. A MWE should start with a
documentclass
command, have a minimal preamble and thenbegin{document}...end{document}
. The code should compile and be as small as possible to demonstrate your problem. Cutting your code down to a MWE may well reveal what your problem actually is. In any case, it is really difficult to help you without more information.– Andrew
yesterday
4
please don't just post disconnected code fragments, post a single small example that we can run to get the error that you are asking about, otherwise it's very hard to guess the error and advise how to fix it.
– David Carlisle
yesterday
1
As David says, please post a full minimal working example: the code should be as small as possible so as to reproduce your error. You should either post a minimal latex document that exhibits the problem or, alternatively, a minimal class file together with a minimal latex document. The key thing is that we should be able to reproduce your error from the code that you post. It is virtually impossible to help you if you don't show us the problem.
– Andrew
yesterday
1
your definition of
maketitleee
should have themakeatletter/makeatother
outside, not inside. There might be other problems (code looks complicated).– jfbu
yesterday
1
There still is a
makeatletter
and amakeatother
in your.cls
file. Remove allmakeatletter
s andmakeatother
s from the.cls
. As I said before if I remove all of them (in the earlier version two pairs, now only one pair), the MWE compiles.– moewe
yesterday