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 am trying to create a new command that represent one word larger than the text.

\newcommand {\Large}{\Large} is that right?

And then I have to integrate the top command in this

\newcommand{\smindexx}[2]{#2 \index{#2}}

I use smindexx as follow \smindexx{\ITerm}{Test} and Test should be larger than the other words.

How can I do that, have someone an idea?

share|improve this question
3  
\renewcommand {\Large}{\Large} defines \Large to be a non-terminating infinite loop \Large expands to \Large which expands to ... But it isn't clear what your intended behaviour is. –  David Carlisle Oct 2 '13 at 11:08
    
I have to write a command like \newcommand{\smindexx}[2]{#2 \index{#2}}, but the word should be in text larger, but not in the index. When the word is larger than the text the co author can see there is a problem with this word. When he correct this word, this command should be turn off. I hope its now clear.... –  blue Oct 2 '13 at 11:56
    
Your question is very unclear. \newcommand{\smindexx}[2]{#2 \index{#2}} defines \smindexx to take two arguments but it discards #1 and uses #2 twice. You show usage as \smindexx{\ITerm}{Test} without saying what \Iterm is. As defined it would be discarded but assuming the definition of \smindexx is changed you presumably want one argument to appear as large text at this point, and the other to go into the index? –  David Carlisle Oct 2 '13 at 12:19
    
\Iterm is not important, because i don't use it in this moment. Therefore is this like \newcommand{\smindexx}[2]{#2 \index{#2}}, because I dont use the first argument, but the second. \smindexx{\ITerm}{Test} Test is here the word in the text and it is the second argument, therefore he goes to the index.. But I want that the word Test in text appears larger.. –  blue Oct 2 '13 at 12:29
add comment

2 Answers

There are some issues with your approach:

Firstly, \newcommand takes the number of arguments in brackets [2] and then refers to the arguments as #1 and #2. So your second code segment should be

\newcommand{\smindexx}[2]{#1 \index{#2}}

And would be called by

\smindexx{\ITerm}{Test}

so that part you got right.

Next, as David Carliste commented, defining \Large as \Large is redundant and may result in a loop. Furthermore, you can't use \newcommand for existing commands, but need \renewcommand.

If you simply want test to be \Large you can simply nest commands:

\newcommand{\smindexx}[2]%
{%
    #2%
    \index{%
              \Large{#2}%
          }%
}

The indentation is superfluous, but I hope it clarifies the idea. The part where you renewcommand \Large is unnecessary.

share|improve this answer
    
There is no compiler dependency. defining \Large to be \Large will loop if you then call \Large. Also the indentation will introduce white space in the output unless you % at the end of each line. I assume you would want \Large to be around #2 (and inside {}) as otherwise it will go into the string to be indexed and sorted –  David Carlisle Oct 2 '13 at 11:46
    
Thanks, I totally forgot about the %; and wasn't sure about the compiler dependency. Updated. –  phi Oct 2 '13 at 11:55
    
Thank you for your help, but don't you think this command is only for the index. Also the word in index is than larger, but not in text. –  blue Oct 2 '13 at 12:06
    
Ooo I am confused.. The top syntax don't work.. David can you please give me an example what do you mean.. Sorry my english is not so good.. :(( –  blue Oct 2 '13 at 12:09
    
I see it now.. I am really confuses ;) –  blue Oct 2 '13 at 12:10
show 1 more comment

I would guess (but it is only a guess as the question has so few details) that you want

\newcommand{\smindexx}[2]{{\Large#1}\index{#2}}

Then \smindexx{abc}{xyz} will typeset abc in large text at this point and make an index entry xyz.

As clarified in comments actually you want

\newcommand{\smindexx}[2]{{\Large#2}\index{#2}}

and re-use #2 twice discarding #1.

share|improve this answer
    
It works ;) Thank you for your help.. My tutor wanted this with newcommand large because he thinks, I can create newcommand Large and then nested newcommand large in newcommand smiindexx. And then when he want this word again normal, he can do this with a newcommand normal.. I notice I don't understand him not really ;) –  blue Oct 2 '13 at 12:41
    
@blue oh that makes more sense, but without the loop. use a new name so \myLarge in the definition of \smindexxx instead of \Large then have \newcommand\myLarge{\Large} and later you can change that to \newcommand\myLarge{} so it does nothing –  David Carlisle Oct 2 '13 at 13:41
    
My Tutor said I can create then \newcommand{\MyLarge}{\Large} ist this syntax right? You wrote the syntax different. You mean \newcommand{\smindexx}[2]{{\MyLarge#2}\index{#2}}? –  blue Oct 3 '13 at 13:46
    
@blue yes that is the same as I wrote. –  David Carlisle Oct 3 '13 at 13:56
    
Carliste thank you, I will try it later ;) –  blue Oct 3 '13 at 14:08
show 4 more comments

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.