Talk:LaTeX/Macros

\obeylines and \obeyspaces
It is probably a good idea if someone works in the \obeylines and \obeyspaces commands in this section, as they can be fairly important when writing your own macro. It is rather confusing to discover (La)TeX treats all whitespace as the same type of spacing glue, and that you need to wrap text you want to preserve the spacing and newlines as you wrote it for in

\begingroup \obeylines \obeyspaces Relevant text here \endgroup

which means that you will probably need to combine your own verbatim environment, and your command:

\newenvironment{\yourverbatim}{\begingroup \obeylines \obeyspaces}{\endgroup} \newcommand{\yourcommand}[n]{do something with #1 .. #n}

and then in your tex file:

\begin{yourverbatim} \yourcommand{ whichever text it is important you preserve the spacing and newslines for, like when you want to generate a verbatim block later on. } \end{yourverbatim}

I don't have enough knowledge of wiki editing to do this cleanly, I'd probably just screw up a perfectly usable page somehow.

- Mike Kamermans (nihongoresources.com)


 * I will do it soon. --Ambrevar (discuss • contribs) 13:40, 4 January 2013 (UTC)
 * I wrote a section including your text in the Plain TeX chapter (as and  belongs to Plain TeX). Thank you for your contribution! --Ambrevar (discuss • contribs) 15:46, 13 January 2013 (UTC)

Example: what to write in a .sty-file
Please provide an example of a .sty-file. Thank you!


 * Done in LaTeX/Creating Packages. This page needs some improvements though. -- Ambrevar (discuss • contribs) 13:40, 4 January 2013 (UTC)

keyval/xkeyval
Maybe someone can add some information about keyval/xkeyval which makes handling of arguments way more comfortable and powerful.


 * Will do it soon. --Ambrevar (discuss • contribs) 13:40, 4 January 2013 (UTC)


 * I wrote a quick example. Actually there is much to tell here and I do not have much time for that. I've put a link to the official documentation. --Ambrevar (discuss • contribs) 15:46, 13 January 2013 (UTC)

A Little Question
In some point there is the sentence "LaTeX will silently ignore it." What does "it" refer to? The LaTeX "old" command or the attempt of definition?

PS.: my thanks to anyone who answer that.


 * Done by someone. --Ambrevar (discuss • contribs) 13:40, 4 January 2013 (UTC)

Multiple default values
The article gives an example of default values for a newcommand, but this method only works with one default value.

Is there a way to give more default values, and if so, please give an example.


 * keyval and xkeyval, as told above. --Ambrevar (discuss • contribs) 13:40, 4 January 2013 (UTC)

Problem with source coloring
In my browser (Chrome) there seems to be a problem with source coloring. As an example the following: Shows the brace preceding name in the same coloring as the brace trailing definition. Since these are not paired, i.e. opening with closing brace, I believe this is in error. Hsmyers (discuss • contribs) 01:50, 20 December 2012 (UTC)


 * This is a known error, not Chrome-specific. --Ambrevar (discuss • contribs) 13:40, 4 January 2013 (UTC)

Expanding arithmetic section
I was reading the section Arithmetic and I find it hardly understandable. It has some packages' names and some examples but nothing else. I would willingly expand it in some weeks, but if somebody wants to do it please go ahead. That is why I marked it to be expanded. I would suggest to make this arithmetic section (if it is expanded enough!) to make it a subsection of the section technical texts as the subsection LaTeX/Mathematics is. I believe that this both packages calc and fp can be explained in greater detail and provide lots of useful functions. (I am working with them ;-))

Thanks and blessings.

unmatched braces
The environment itself is a group. Making the section a bit needless. Using curly braces for extra grouping is not needed and indeed throws an error. The concept of grouping should be addressed at LaTeX Groups. For now, i'll delete that little section because all it adds is confusion.

\newcommand with two options
Apparently \newcommand can be used with two options, the number of variables, and the default value of the first variable. This information seems to be missing from this page, and it is hard to find. I think somebody more knowledgeable than myself ought to insert the syntax and if possible, also an example.

Add example with \ensuremath
It'd be nice to have an example and explanation of \ensuremath, but it's not a section I write today. I found some StackExchange questions/answers with info:
 * TeX StackExchange "Proper way to use ensuremath ..."
 * TeX StackExchange "When not to use ensuremath for math macro?"

Columbus240 (discuss • contribs) 15:52, 2 March 2022 (UTC)