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.

I would like put picture into table, and my idea is define new command as below>

  • \newcommand{\EJ471}{\includegraphics[scale=0.150]{EJ_471.jpg}}

But compiler reports an error. If I use the command name for example \EJa, everything is all right. I've read similar questions as

But still I don't understand why it does not work.

share|improve this question
4  
What don't you understand? In my opinion the FAQ is really clear: tex.ac.uk/cgi-bin/texfaq2html?label=linmacnames –  Marco Daniel Aug 10 '12 at 15:28
    
@Jafan It's not normal here to include 'thanks' or similar: voting is the best way to indicate that something is helpful. –  Joseph Wright Aug 10 '12 at 16:53

2 Answers 2

up vote 16 down vote accepted

A long time ago in a galaxy far, far away....

someone wrote this:

http://www.elec.ryukoku.ac.jp/~fujii/pub/ftp/incoming/styles/kth.se/numdef.sty

share|improve this answer
1  
You are impressive! –  Marco Daniel Aug 10 '12 at 19:12
2  
Having found that via google (it was removed from ctan in 1996:-) I have put a copy here code.google.com/p/dpctex/source/browse/#svn%2Ftrunk%2Fnumdef –  David Carlisle Aug 10 '12 at 20:37

By the rules of TeX syntax, the "name" of a macro that starts with a \ (backslash) character must either

  • consist of a single non-alphanumeric character. Some examples: \, (insert thin space), \\ (insert line break), \[ (open display math), and \) (close inline math)

or

  • contain only uppercase and lowercase alphabetic characters: a-z and A-Z. No numerals, and no other characters belonging to non-letter categories either. (Well, there are certain ways of assigning "letter-category" status to non-letter characters, but that's a topic for a different discussion.)

Therefore, \EJ471 is not a valid macro name.

However, you could define a somewhat more general macro:

\newcommand{\EJ}[1]{\includegraphics[scale=0.150]{EJ_#1.jpg}}

and use it, as in \EJ{471}, to pass EJ_471.jpg to the \includegraphics command. If you needed to process further jpg files that start with EJ_ (and end in .jpg, of course), you could simply keep invoking this macro with the appropriate arguments.

share|improve this answer
    
Well, there are certain ways of assigning "letter-category" status to non-letter characters, but that's a topic for a different discussion. -- I think this is the correct place ;-). The catcodes are the reasons for this. –  Marco Daniel Aug 10 '12 at 17:24
    
@MarcoDaniel - I have a feeling that the OP isn't all that interested in learning about catcodes just so that he/she can make \EJ471 into a valid TeX macro name after all. However, I may be wrong. :-) Please feel free to provide a separate, longer answer. –  Mico Aug 10 '12 at 17:40
1  
@MarcoDaniel As Mico says, the question here seems to be focussed on one part of the story. Catcodes are 'advanced', and moreover we've already got questions about them. –  Joseph Wright Aug 10 '12 at 18:14

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.