I know how to create a new command or an environment. I think it will much better if I can specify name of the arguments. For example in framebox command and array environment below, we know exactly what're the arguments that should be passed.



So far, I've tried


\def\testdef#1#2{#1 #2}

\newcommand{\testcommand}[2]{#1 #2}







and you all can see, \testdef{arg1}{arg2} just print arg1 and arg2 while I need to naming them with, for example, name and value. It should be


The same goes also for \testcommand and testenv. So, How can I do that?


These pictures is taken from TeXstudio.

In picture #1, we see what are arguments for \framebox.

enter image description here

while in picture #2, we just see \testdef{arg1}{arg2}.

enter image description here

Is it behavior of Latex editor? or we can tune it through latex macro?

  • Your question isn't very clear but I think you are looking for a syntax like \testdef{arg1=value1, arg2=value2} in which case you should look at the keyval package (or extended versions such as xkeyval or l3keys) – David Carlisle May 7 '14 at 8:18
  • I don't really understad what you want. In case of \def you are just asking for two usual arguments {…}{…}, optionals are a bit more tricky. In \newcommand you are doing the same, you need \newcommand\testcommand[2][]{#1 #2} or something similar. And in the \newenvironment there is a problem, the arguments can only be used in the “opening”; usually in the \begin some variables are defined with the arguments, and then in the \end they are used. Again, you need \newenvironment{testenv}[2][]{…}{…}. Take a look at xparse. – Manuel May 7 '14 at 8:19
  • 1
    In the documentation, something like \begin{array}[<pos>]{<cols>} uses <pos> and <cols> as place-holders to show what is going on, but in the code you still need #1, #2, etc. In TeX parameters have numbers, not names (you can work-around this in LuaTeX, but that I know of this has only been done in ConTeXt and not in LaTeX). – Joseph Wright May 7 '14 at 8:21
  • 1
    Your edited question is just about the help prompts added by that editor, it is nothing to do with TeX at all, sorry I can't help as I don't use that editor. – David Carlisle May 7 '14 at 10:27
  • 1
    TeXstudio stores the auto-completion data as a series of .cwl files: see e.g. tex.stackexchange.com/questions/79643/… for some discussion of altering/adding them. The thing is that this requires knowing what commands to add: are you looking to extend by a 'fixed' set of commands? – Joseph Wright May 7 '14 at 10:38

You have to create a .cwl file and manually activate in in Options -> completion. See the FAQ and the manual.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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