Error: custom new command can be used only in preamble (not expected)How can I fix a “*.sty not found”...

What does each site of a vanilla 9.1 installation do?

Is divide-by-zero a security vulnerability?

Why do phishing e-mails use faked e-mail addresses instead of the real one?

Every subset equal to original set?

Should I use HTTPS on a domain that will only be used for redirection?

How to disable or uninstall iTunes under High Sierra without disabling SIP

Can metaphors be used for other purposes than for stylistic effect and to form an allegory?

Make me a metasequence

Where is this quote about overcoming the impossible said in "Interstellar"?

How to merge row in the first column in LaTeX

Lock enemy's y-axis when using Vector3.MoveTowards to follow the player

Must 40/100G uplink ports on a 10G switch be connected to another switch?

A bug in Excel? Conditional formatting for marking duplicates also highlights unique value

Was it really inappropriate to write a pull request for the company I interviewed with?

1970s scifi/horror novel where protagonist is used by a crablike creature to feed its larvae, goes mad, and is defeated by retraumatising him

GPL code private and stolen

How to use math.log10 function on whole pandas dataframe

When do _WA_Sys_ statistics Get Updated?

Meaning of word ягоза

Reason why dimensional travelling would be restricted

Inconsistent behaviour between dict.values() and dict.keys() equality in Python 3.x and Python 2.7

Giving a talk in my old university, how prominently should I tell students my salary?

Do AL rules let me pick different starting equipment?

PTIJ: Aharon, King of Egypt



Error: custom new command can be used only in preamble (not expected)


How can I fix a “*.sty not found” error in Lyx, when it works in pdflatex?! LaTeX error: “kernel/command-not-defined” ! ! Control sequence str_case:nnn undefinedgetting error “could not start command pdflatex -synctex=1 -interaction=nonstopmode %.tex”Error: Could not start the command: pdflatex.exe -synctex=1 -interaction=nonstopmode “eigenvector or eigenvalue decompositions”.texError: Could not start the command: pdflatex.exe -synctex=1 -interaction=nonstopmode “template”.texNew ACM Latex compilation error: ! pdfTeX error (font expansion): auto expansion is only possible with scalable fontsLaTeX Error: Can be used only in preamble. But I have it in preamble













0















I'm creating a custom class for a CV template, now it is complaining about a custom command with:



! LaTeX Error: Can be used only in preamble.
l.13 makecontact


But as far as I can tell there is no preamble only command in my custom macro.



Here is my simple CV file:



documentclass{cv}
usepackage[english]{babel}
usepackage[utf8]{inputenc}

name{John}{Smith}
email{john.smith@foobar.com}
address{1234 avenue street}{suite 123}{Neverland}{NX}{Somewhere}{123456-1234}
github{agithubacct}
linkedin{linkedinprofile}
website{www.website.com}

begin{document}
makecontact

A short academic summary.

end{document}


And my very shortened class file:



NeedsTeXFormat{LaTeX2e}
ProvidesClass{cv}[2019/03/05 My custom CV class]
LoadClass{memoir}
RequirePackage{hyperref}
RequirePackage{xcolor}
pagestyle{empty}


newcommand{name}[2]{
def@name{#1}
def@surname{#2}
def@fullname{#1 #2}
}

newcommand{email}[1]{def@email{#1}}
newcommand{website}[1]{def@website{#1}}
newcommand{phone}[1]{def@phone{#1}}
newcommand{github}[1]{def@github{#1}}
newcommand{linkedin}[1]{def@linkedin{#1}}

newcommand{address}[6]{
def@addra{#1}
def@addrb{#2}
def@city{#3}
def@state{#4}
def@country{#5}
def@zip{#6}
}


newcommand{makecontact}{
begin{center}
{Huge{@fullname}}

vspace{1.5mm}
makebox[0pt][c]{
href{mailto:@email?subject=Contact%20regarding%20your%20CV}{@email}
enspace{largetextperiodcentered}enspace
href{https://github.com/@github}{gh:@github}
enspace{largetextperiodcentered}enspace
href{http://@website}{@website}
}

vspace{0.5mm}
makebox[0pt][c]{
@addra @addrb
enspace{largetextperiodcentered}enspace
@city
enspace{largetextperiodcentered}enspace
@stateRequirePackage{calc}
enspace{largetextperiodcentered}enspace
@country
enspace{largetextperiodcentered}enspace
@zip
}
end{center}
}

endinput


I could not figure out why this is hapenning while compiling with pdftex.









share























  • Remove RequirePackage{calc} after @state. You also have several unprotected end-of-lines that will produce unwanted spaces.

    – egreg
    1 min ago


















0















I'm creating a custom class for a CV template, now it is complaining about a custom command with:



! LaTeX Error: Can be used only in preamble.
l.13 makecontact


But as far as I can tell there is no preamble only command in my custom macro.



Here is my simple CV file:



documentclass{cv}
usepackage[english]{babel}
usepackage[utf8]{inputenc}

name{John}{Smith}
email{john.smith@foobar.com}
address{1234 avenue street}{suite 123}{Neverland}{NX}{Somewhere}{123456-1234}
github{agithubacct}
linkedin{linkedinprofile}
website{www.website.com}

begin{document}
makecontact

A short academic summary.

end{document}


And my very shortened class file:



NeedsTeXFormat{LaTeX2e}
ProvidesClass{cv}[2019/03/05 My custom CV class]
LoadClass{memoir}
RequirePackage{hyperref}
RequirePackage{xcolor}
pagestyle{empty}


newcommand{name}[2]{
def@name{#1}
def@surname{#2}
def@fullname{#1 #2}
}

newcommand{email}[1]{def@email{#1}}
newcommand{website}[1]{def@website{#1}}
newcommand{phone}[1]{def@phone{#1}}
newcommand{github}[1]{def@github{#1}}
newcommand{linkedin}[1]{def@linkedin{#1}}

newcommand{address}[6]{
def@addra{#1}
def@addrb{#2}
def@city{#3}
def@state{#4}
def@country{#5}
def@zip{#6}
}


newcommand{makecontact}{
begin{center}
{Huge{@fullname}}

vspace{1.5mm}
makebox[0pt][c]{
href{mailto:@email?subject=Contact%20regarding%20your%20CV}{@email}
enspace{largetextperiodcentered}enspace
href{https://github.com/@github}{gh:@github}
enspace{largetextperiodcentered}enspace
href{http://@website}{@website}
}

vspace{0.5mm}
makebox[0pt][c]{
@addra @addrb
enspace{largetextperiodcentered}enspace
@city
enspace{largetextperiodcentered}enspace
@stateRequirePackage{calc}
enspace{largetextperiodcentered}enspace
@country
enspace{largetextperiodcentered}enspace
@zip
}
end{center}
}

endinput


I could not figure out why this is hapenning while compiling with pdftex.









share























  • Remove RequirePackage{calc} after @state. You also have several unprotected end-of-lines that will produce unwanted spaces.

    – egreg
    1 min ago
















0












0








0








I'm creating a custom class for a CV template, now it is complaining about a custom command with:



! LaTeX Error: Can be used only in preamble.
l.13 makecontact


But as far as I can tell there is no preamble only command in my custom macro.



Here is my simple CV file:



documentclass{cv}
usepackage[english]{babel}
usepackage[utf8]{inputenc}

name{John}{Smith}
email{john.smith@foobar.com}
address{1234 avenue street}{suite 123}{Neverland}{NX}{Somewhere}{123456-1234}
github{agithubacct}
linkedin{linkedinprofile}
website{www.website.com}

begin{document}
makecontact

A short academic summary.

end{document}


And my very shortened class file:



NeedsTeXFormat{LaTeX2e}
ProvidesClass{cv}[2019/03/05 My custom CV class]
LoadClass{memoir}
RequirePackage{hyperref}
RequirePackage{xcolor}
pagestyle{empty}


newcommand{name}[2]{
def@name{#1}
def@surname{#2}
def@fullname{#1 #2}
}

newcommand{email}[1]{def@email{#1}}
newcommand{website}[1]{def@website{#1}}
newcommand{phone}[1]{def@phone{#1}}
newcommand{github}[1]{def@github{#1}}
newcommand{linkedin}[1]{def@linkedin{#1}}

newcommand{address}[6]{
def@addra{#1}
def@addrb{#2}
def@city{#3}
def@state{#4}
def@country{#5}
def@zip{#6}
}


newcommand{makecontact}{
begin{center}
{Huge{@fullname}}

vspace{1.5mm}
makebox[0pt][c]{
href{mailto:@email?subject=Contact%20regarding%20your%20CV}{@email}
enspace{largetextperiodcentered}enspace
href{https://github.com/@github}{gh:@github}
enspace{largetextperiodcentered}enspace
href{http://@website}{@website}
}

vspace{0.5mm}
makebox[0pt][c]{
@addra @addrb
enspace{largetextperiodcentered}enspace
@city
enspace{largetextperiodcentered}enspace
@stateRequirePackage{calc}
enspace{largetextperiodcentered}enspace
@country
enspace{largetextperiodcentered}enspace
@zip
}
end{center}
}

endinput


I could not figure out why this is hapenning while compiling with pdftex.









share














I'm creating a custom class for a CV template, now it is complaining about a custom command with:



! LaTeX Error: Can be used only in preamble.
l.13 makecontact


But as far as I can tell there is no preamble only command in my custom macro.



Here is my simple CV file:



documentclass{cv}
usepackage[english]{babel}
usepackage[utf8]{inputenc}

name{John}{Smith}
email{john.smith@foobar.com}
address{1234 avenue street}{suite 123}{Neverland}{NX}{Somewhere}{123456-1234}
github{agithubacct}
linkedin{linkedinprofile}
website{www.website.com}

begin{document}
makecontact

A short academic summary.

end{document}


And my very shortened class file:



NeedsTeXFormat{LaTeX2e}
ProvidesClass{cv}[2019/03/05 My custom CV class]
LoadClass{memoir}
RequirePackage{hyperref}
RequirePackage{xcolor}
pagestyle{empty}


newcommand{name}[2]{
def@name{#1}
def@surname{#2}
def@fullname{#1 #2}
}

newcommand{email}[1]{def@email{#1}}
newcommand{website}[1]{def@website{#1}}
newcommand{phone}[1]{def@phone{#1}}
newcommand{github}[1]{def@github{#1}}
newcommand{linkedin}[1]{def@linkedin{#1}}

newcommand{address}[6]{
def@addra{#1}
def@addrb{#2}
def@city{#3}
def@state{#4}
def@country{#5}
def@zip{#6}
}


newcommand{makecontact}{
begin{center}
{Huge{@fullname}}

vspace{1.5mm}
makebox[0pt][c]{
href{mailto:@email?subject=Contact%20regarding%20your%20CV}{@email}
enspace{largetextperiodcentered}enspace
href{https://github.com/@github}{gh:@github}
enspace{largetextperiodcentered}enspace
href{http://@website}{@website}
}

vspace{0.5mm}
makebox[0pt][c]{
@addra @addrb
enspace{largetextperiodcentered}enspace
@city
enspace{largetextperiodcentered}enspace
@stateRequirePackage{calc}
enspace{largetextperiodcentered}enspace
@country
enspace{largetextperiodcentered}enspace
@zip
}
end{center}
}

endinput


I could not figure out why this is hapenning while compiling with pdftex.







pdftex





share












share










share



share










asked 7 mins ago









LinLin

3117




3117













  • Remove RequirePackage{calc} after @state. You also have several unprotected end-of-lines that will produce unwanted spaces.

    – egreg
    1 min ago





















  • Remove RequirePackage{calc} after @state. You also have several unprotected end-of-lines that will produce unwanted spaces.

    – egreg
    1 min ago



















Remove RequirePackage{calc} after @state. You also have several unprotected end-of-lines that will produce unwanted spaces.

– egreg
1 min ago







Remove RequirePackage{calc} after @state. You also have several unprotected end-of-lines that will produce unwanted spaces.

– egreg
1 min ago












0






active

oldest

votes











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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478117%2ferror-custom-new-command-can-be-used-only-in-preamble-not-expected%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478117%2ferror-custom-new-command-can-be-used-only-in-preamble-not-expected%23new-answer', 'question_page');
}
);

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