Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

What follows is my example doofus.sty:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{doofus}%
[2014/01/01 v0.01a LaTeX doofus package]%\filedate\space\fileversion\space 
\typeout{Package doofus, \csname ver@doofus.sty\endcsname%
^^ Copyright (C) 2014 ^^J}

\RequirePackage{calc}
\RequirePackage{xkeyval}[2006/11/18]
\usepackage{ifthen}
\usepackage{etoolbox}

\newbool{@epubstate}
\boolfalse{@epubstate}
\DeclareOption{epub}{\booltrue{@epubstate}}
\ProcessOptions%

\ifbool{@epubstate}{\newcommand{\doofus}{\textcolor{black}{7\spadesuit}}
\newcommand{\doofus2}{\textcolor{black}{6\spadesuit}}}
{\newcommand{\doofus}{\textcolor{red}{7\heartsuit}}\newcommand{\doofus2}{\textcolor{red}{6\heartsuit}}}

Now the original doofus.tex with multiple commands:

\documentclass[english]{letter}
\usepackage[T1]{fontenc}
\usepackage{color}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage[]{doofus}
\usepackage{color}
\usepackage{etoolbox}

\makeatother
\begin{document}
This is a test document for the the doofus boolean example;

Which one appears when I type $\doofus   \doofustwo $?
\end{document}

This returns the following error:

! LaTeX Error: Command \doofus already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation. Type  H <return>  for immediate help.  ...                                    

l.19 ...d{\doofus2}{\textcolor{red}{6\heartsuit}}}
? X
share|improve this question
4  
You can't have numbers in macro names. Well, not easily anyway, so better not to use them. So instead of \newcommand{\doofus2}{...}, use \newcommand{\doofusTwo}{...} and that should work. –  Peter Grill Aug 6 at 22:23
4  
@daemondave: Do you really want to write a package? Perhaps you should get the basics first ;-) –  Christian Hupfer Aug 6 at 22:28
    
Hi. thank you, no I really don't want to do packages first but that's what I need to do... –  daemondave Aug 6 at 23:56
    
It would still be more effective not to start by trying to create packages. (Quicker, more efficient, better results if you start simpler.) Note that you do not need \makeatletter for \usepackage commands. –  cfr Aug 7 at 1:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.