Defined command only works in preamble
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
ProvidesClasscustom[a custom class]
NeedsTeXFormatLaTeX2e
DeclareOption*
PassOptionsToClassCurrentOptionscrreprt
ProcessOptionsrelax
LoadClass[usegeometry]scrreprt
RequirePackagegraphicx
RequirePackageplex-serif
% Small Caps
makeatletter
newlengthfake@f
newlengthfake@c
deffakesc#1%
begingroup%
xdeffake@namecsnamecurr@fontshape/f@sizeendcsname%
fontsizefontdimen8fake@namebaselineskipselectfont%
uppercase#1%
endgroup%
makeatother
newcommandfauxsc[1]fauxschelper#1 relaxrelax
deffauxschelper#1 #2relax%
fauxschelphelp#1relaxrelax%
ifrelax#2relaxelse fauxschelper#2relaxfi%
defHscale.83defVscale.72defCscale1.00
deffauxschelphelp#1#2relax{%
ifnum`#1>``ifnum`#1<`scaleboxHscale[Vscale]uppercase#1else%
scaleboxCscale[1]#1fielsescaleboxCscale[1]#1fi%
ifxrelax#2relaxelsefauxschelphelp#2relaxfi
makeatletter
newcommandmaketitleee
fauxsc@title
makeatother
Document
documentclass[a4paper, 12pt, oneside]custom
titleTitle
authorAuthor
begindocument
maketitleee
enddocument
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
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
ProvidesClasscustom[a custom class]
NeedsTeXFormatLaTeX2e
DeclareOption*
PassOptionsToClassCurrentOptionscrreprt
ProcessOptionsrelax
LoadClass[usegeometry]scrreprt
RequirePackagegraphicx
RequirePackageplex-serif
% Small Caps
makeatletter
newlengthfake@f
newlengthfake@c
deffakesc#1%
begingroup%
xdeffake@namecsnamecurr@fontshape/f@sizeendcsname%
fontsizefontdimen8fake@namebaselineskipselectfont%
uppercase#1%
endgroup%
makeatother
newcommandfauxsc[1]fauxschelper#1 relaxrelax
deffauxschelper#1 #2relax%
fauxschelphelp#1relaxrelax%
ifrelax#2relaxelse fauxschelper#2relaxfi%
defHscale.83defVscale.72defCscale1.00
deffauxschelphelp#1#2relax{%
ifnum`#1>``ifnum`#1<`scaleboxHscale[Vscale]uppercase#1else%
scaleboxCscale[1]#1fielsescaleboxCscale[1]#1fi%
ifxrelax#2relaxelsefauxschelphelp#2relaxfi
makeatletter
newcommandmaketitleee
fauxsc@title
makeatother
Document
documentclass[a4paper, 12pt, oneside]custom
titleTitle
authorAuthor
begindocument
maketitleee
enddocument
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 thenbegindocument...enddocument
. 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
Nov 13 '18 at 7:10
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
Nov 13 '18 at 7:46
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
Nov 13 '18 at 8:02
1
your definition ofmaketitleee
should have themakeatletter/makeatother
outside, not inside. There might be other problems (code looks complicated).
– jfbu
Nov 13 '18 at 8:28
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
Nov 13 '18 at 8:52
|
show 12 more comments
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
ProvidesClasscustom[a custom class]
NeedsTeXFormatLaTeX2e
DeclareOption*
PassOptionsToClassCurrentOptionscrreprt
ProcessOptionsrelax
LoadClass[usegeometry]scrreprt
RequirePackagegraphicx
RequirePackageplex-serif
% Small Caps
makeatletter
newlengthfake@f
newlengthfake@c
deffakesc#1%
begingroup%
xdeffake@namecsnamecurr@fontshape/f@sizeendcsname%
fontsizefontdimen8fake@namebaselineskipselectfont%
uppercase#1%
endgroup%
makeatother
newcommandfauxsc[1]fauxschelper#1 relaxrelax
deffauxschelper#1 #2relax%
fauxschelphelp#1relaxrelax%
ifrelax#2relaxelse fauxschelper#2relaxfi%
defHscale.83defVscale.72defCscale1.00
deffauxschelphelp#1#2relax{%
ifnum`#1>``ifnum`#1<`scaleboxHscale[Vscale]uppercase#1else%
scaleboxCscale[1]#1fielsescaleboxCscale[1]#1fi%
ifxrelax#2relaxelsefauxschelphelp#2relaxfi
makeatletter
newcommandmaketitleee
fauxsc@title
makeatother
Document
documentclass[a4paper, 12pt, oneside]custom
titleTitle
authorAuthor
begindocument
maketitleee
enddocument
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
ProvidesClasscustom[a custom class]
NeedsTeXFormatLaTeX2e
DeclareOption*
PassOptionsToClassCurrentOptionscrreprt
ProcessOptionsrelax
LoadClass[usegeometry]scrreprt
RequirePackagegraphicx
RequirePackageplex-serif
% Small Caps
makeatletter
newlengthfake@f
newlengthfake@c
deffakesc#1%
begingroup%
xdeffake@namecsnamecurr@fontshape/f@sizeendcsname%
fontsizefontdimen8fake@namebaselineskipselectfont%
uppercase#1%
endgroup%
makeatother
newcommandfauxsc[1]fauxschelper#1 relaxrelax
deffauxschelper#1 #2relax%
fauxschelphelp#1relaxrelax%
ifrelax#2relaxelse fauxschelper#2relaxfi%
defHscale.83defVscale.72defCscale1.00
deffauxschelphelp#1#2relax{%
ifnum`#1>``ifnum`#1<`scaleboxHscale[Vscale]uppercase#1else%
scaleboxCscale[1]#1fielsescaleboxCscale[1]#1fi%
ifxrelax#2relaxelsefauxschelphelp#2relaxfi
makeatletter
newcommandmaketitleee
fauxsc@title
makeatother
Document
documentclass[a4paper, 12pt, oneside]custom
titleTitle
authorAuthor
begindocument
maketitleee
enddocument
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 Nov 13 '18 at 10:08
tecosaur
asked Nov 13 '18 at 7:03
tecosaurtecosaur
1898
1898
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 thenbegindocument...enddocument
. 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
Nov 13 '18 at 7:10
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
Nov 13 '18 at 7:46
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
Nov 13 '18 at 8:02
1
your definition ofmaketitleee
should have themakeatletter/makeatother
outside, not inside. There might be other problems (code looks complicated).
– jfbu
Nov 13 '18 at 8:28
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
Nov 13 '18 at 8:52
|
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 thenbegindocument...enddocument
. 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
Nov 13 '18 at 7:10
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
Nov 13 '18 at 7:46
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
Nov 13 '18 at 8:02
1
your definition ofmaketitleee
should have themakeatletter/makeatother
outside, not inside. There might be other problems (code looks complicated).
– jfbu
Nov 13 '18 at 8:28
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
Nov 13 '18 at 8:52
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 begindocument...enddocument
. 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
Nov 13 '18 at 7:10
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 begindocument...enddocument
. 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
Nov 13 '18 at 7:10
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
Nov 13 '18 at 7:46
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
Nov 13 '18 at 7:46
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
Nov 13 '18 at 8:02
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
Nov 13 '18 at 8:02
1
1
your definition of
maketitleee
should have the makeatletter/makeatother
outside, not inside. There might be other problems (code looks complicated).– jfbu
Nov 13 '18 at 8:28
your definition of
maketitleee
should have the makeatletter/makeatother
outside, not inside. There might be other problems (code looks complicated).– jfbu
Nov 13 '18 at 8:28
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
Nov 13 '18 at 8:52
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
Nov 13 '18 at 8:52
|
show 12 more comments
1 Answer
1
active
oldest
votes
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
Nov 13 '18 at 8:45
@tecosaur I tried, of course.
– egreg
Nov 13 '18 at 8:48
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
Nov 13 '18 at 9:30
However, this does solve the issue which I had (at least the first one). Thanks :)
– tecosaur
Nov 13 '18 at 10:03
3
In some situations better thanmakeatletter..makeatother
is:begingroupmakeatletter@firstofoneendgroup <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
Nov 13 '18 at 11:13
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
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
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
Nov 13 '18 at 8:45
@tecosaur I tried, of course.
– egreg
Nov 13 '18 at 8:48
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
Nov 13 '18 at 9:30
However, this does solve the issue which I had (at least the first one). Thanks :)
– tecosaur
Nov 13 '18 at 10:03
3
In some situations better thanmakeatletter..makeatother
is:begingroupmakeatletter@firstofoneendgroup <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
Nov 13 '18 at 11:13
add a comment |
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
Nov 13 '18 at 8:45
@tecosaur I tried, of course.
– egreg
Nov 13 '18 at 8:48
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
Nov 13 '18 at 9:30
However, this does solve the issue which I had (at least the first one). Thanks :)
– tecosaur
Nov 13 '18 at 10:03
3
In some situations better thanmakeatletter..makeatother
is:begingroupmakeatletter@firstofoneendgroup <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
Nov 13 '18 at 11:13
add a comment |
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 Nov 13 '18 at 8:49
answered Nov 13 '18 at 8:42
egregegreg
712k8618933179
712k8618933179
I see, however — if I remove themakeatletter
andmakeatother
it doesn't work.
– tecosaur
Nov 13 '18 at 8:45
@tecosaur I tried, of course.
– egreg
Nov 13 '18 at 8:48
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
Nov 13 '18 at 9:30
However, this does solve the issue which I had (at least the first one). Thanks :)
– tecosaur
Nov 13 '18 at 10:03
3
In some situations better thanmakeatletter..makeatother
is:begingroupmakeatletter@firstofoneendgroup <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
Nov 13 '18 at 11:13
add a comment |
I see, however — if I remove themakeatletter
andmakeatother
it doesn't work.
– tecosaur
Nov 13 '18 at 8:45
@tecosaur I tried, of course.
– egreg
Nov 13 '18 at 8:48
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
Nov 13 '18 at 9:30
However, this does solve the issue which I had (at least the first one). Thanks :)
– tecosaur
Nov 13 '18 at 10:03
3
In some situations better thanmakeatletter..makeatother
is:begingroupmakeatletter@firstofoneendgroup <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
Nov 13 '18 at 11:13
I see, however — if I remove the
makeatletter
and makeatother
it doesn't work.– tecosaur
Nov 13 '18 at 8:45
I see, however — if I remove the
makeatletter
and makeatother
it doesn't work.– tecosaur
Nov 13 '18 at 8:45
@tecosaur I tried, of course.
– egreg
Nov 13 '18 at 8:48
@tecosaur I tried, of course.
– egreg
Nov 13 '18 at 8:48
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
Nov 13 '18 at 9:30
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
Nov 13 '18 at 9:30
However, this does solve the issue which I had (at least the first one). Thanks :)
– tecosaur
Nov 13 '18 at 10:03
However, this does solve the issue which I had (at least the first one). Thanks :)
– tecosaur
Nov 13 '18 at 10:03
3
3
In some situations better than
makeatletter..makeatother
is: begingroupmakeatletter@firstofoneendgroup <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
Nov 13 '18 at 11:13
In some situations better than
makeatletter..makeatother
is: begingroupmakeatletter@firstofoneendgroup <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
Nov 13 '18 at 11:13
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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 thenbegindocument...enddocument
. 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
Nov 13 '18 at 7:10
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
Nov 13 '18 at 7:46
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
Nov 13 '18 at 8:02
1
your definition of
maketitleee
should have themakeatletter/makeatother
outside, not inside. There might be other problems (code looks complicated).– jfbu
Nov 13 '18 at 8:28
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
Nov 13 '18 at 8:52