Imagine I define a new command as :  \newcommand{\seagal}{$\sigma$-algebra}   and use it as follows :  A \seagal is defined as   This will produce a text where is will have "-algebrais defined as" and not "-algebra is defined as" : a space is missing. When I write  \mathscr{M} is indeed a \seagal.   though, I don't have a space and I shouldn't have one.  How could I produce a newcommand that handles both cases correctly ?
2572
I have a definition:  \newcommand{\arnold}{Arnold Schwarzenegger}   When I refer to it by:  \arnold is a   it is rendered as:   Arnold Schwarzeneggeris a    In order to have a space in front of "is" I would need to write  \arnold\ is a   Is there some other shorter way?
54017
I am trying to define a command that takes two arguments, where one is optional. If the optional argument isn't given I would like the compulsory argument to be used for the optional argument.  For example:  \necommand{\foo}[2][#2]{#1 foo(#2)}   which would return:  IN: \foo[hello]{hi}      OUT: hello foo(hi) IN: \foo{hi}             OUT: hi foo(hi)   Ideally it would be nice to keep it simple and use standard LaTeX with no packages. Thanks in advance!
118677
I'm wondering about the best way to do an explicit space character (I don't even know what it's properly called), like the ones you get in the \begin{verbatim*} environment. The closest I've found is  \sqcup   in math mode, but it seems like a bit of a hack to me. Is there any text symbol for what I'm looking for?
65028
I set this new command:  \newcommand{\dd}{{\rm d}}   I want to set the same command but now in a generic way. Something like that:  \newcommand{\##}{{\rm #}}   How to do that?  Edit: The new command that I set (\newcommand{\dd}{{\rm d}}) only works for the letter d right?  I want to write the same new command but now working with any letter.
38213
I have the following question:    $\textbf{Question}:$ Let $\mathcal{F}_1$ and $\mathcal{F}_2$ be two algebras. Is $\mathcal{F}_1 \cap \mathcal{F}_2$ a $\sigma$-algebra?  I believe the answer is no. I know the definition of an algebra and the definition of $\sigma$-algebra.    I'm assuming I need to show that the intersection of the finite unions of each algebra is finite, but then I get stuck trying to work out how to show it is not a $\sigma$-algebra.  All help is appreciated.  Many thanks, John
86019
I'm having some problems with lines that turn out to be too long. There are correct hyphenation rules for the word but they aren't being applied.  Let me first give the sentence that is too long:  An isomorphism that maps a graph to itself is called an \concept{automorphism}.   The command concept is defined as follows  \newcommand{\concept}[1]{\index{#1}\marginpar{\raggedright\textbf{#1}}\textbf{#1}}   The problem seems to be that words inside \concept aren't being hyphenated. How can I fix this? If I type   An isomorphism that maps a graph to itself is called an \textbf{automorphism}.   then the word is hyphenated perfectly. So I would now like to have the command \concept behave the same way, i.e. allow concepts to be hyphenated according to the standard rules.
31700
After you define a command using \newcommand, is it possible to undefine it?  My motivation is that I'm writing a thesis, where each chapter is in a separate source file. Some chapters define their own commands that are used nowhere else, so I'd like them to be visible only within that chapter.   I'd therefore like to be able to do something like:  \chapter{Some Chapter} \newcommand{foo}{...} ... % chapter body \forgetcommand{foo} % end of chapter   Is there anything like the fictitious \forgetcommand macro above?
116324
I'm trying to get \xspace to add a whitespace before “ if it is an auto quote using csquotes. Here is an MWE:  \documentclass{minimal}  \usepackage[autostyle,german=guillemets]{csquotes}  \usepackage{xspace}   \MakeAutoQuote{(}{)}  \def\test{test\xspace}  \begin{document}  Hello, \test (after command.)  \end{document}   It doesn't do what I want, no matter how hard I try... what am I missing?  EDIT: more info: in the meantime I figured that even this  \def\qq{\csq@oqopen} Hello, \test \qq after command)   will not work. Something is going on here that makes \xspace think it must not add a space. But I am lost as to why.
32487
As far as I understand, whatever can be done using DeclareMathOperator can also be achieved using newcommand, but not the other way around. If this is the case, what are the circumstances where DeclareMathOperator is the better choice? When should I take solely newcommand?  I found a question regarding , and I wonder what other aspects should be taken into consideration when it comes to choosing which method to use when defining math operators.
38685
So I've read a few times about this, the “moving arguments” and all that. But what does it really mean? Could someone explain in a few words what is going on at the TeX level, what is the difference between these two kinds of commands? Furthermore, when do we need to use \protect and why?
67648
I have a collection of files and directories with strange names, they contain spaces and the special characters \, *, ), ( and ?. All of them cause problems when I try to use them in the command line or scripts, e.g.:    $ cd space dir bash: cd: space: No such file or directory  $ cat space file cat: space: No such file or directory cat: file: No such file or directory  $ cat ( bash: syntax error near unexpected token `newline'  $ echo content &gt;\ &gt; ^C  $ ls ? (  )  *  ?  \   How do I enter file or directory names that contain special characters in the terminal?
123851
I am trying to create a command to modify fontsize with one parameter, it seems that the paramater is not expanding properly:  \newcommand{\mycfs}[1]{\fontsize{#1pt}{1.2*#1pt}}
87259
Most commands in Latex are written with the arguments inside braces following the command: \command{arguments}. But text formatting options, like \em, or \scriptsize are usually written inside the braces, like {\em some italicised text}. Why is this? What makes these commands different? I'm particularly asking because it seems to make standardisation - of which LaTeX really appears badly in need - more difficult.
26223
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.
46150
To write some documentation, I would like the ability to define a command such as  \showcase{x^{y}\in\Omega}   which expands to something roughly equivalent to  \verb|x^{y}\in\Omega| &amp; $x^{y}\in\Omega$ \\   so that I can show what the latex code looks like and how does it show on the document.  Now I now that it isn't really possible to use \verb for this because it's really fragile and you can't pass arguments from a macro to it. But, assuming that I'm not trying to write anything crazy in the argument to \showcase (e.g. braces are always balanced, I don't care much if spaces are collapsed, no %'s inside), is there a way to define such a command?  Update  \detokenize does (almost) exactly what I want. Take the following example  \newcommand\showcase[1]{{\ttfamily\detokenize{#1}} &amp; $#1$} \begin{tabular}{cc|cc} \showcase{x^{y}}      &amp; \showcase{\hat{x}, \bar{x}} \\ \showcase{x_{y}}      &amp; \showcase{f\colon X \to Y} \\ \showcase{x'}         &amp; \showcase{\sqrt{x+2}} \\ \showcase{x''_{2}}    &amp; \showcase{2 &lt; x \leq 4} \\ \showcase{A^{1}_{2}}  &amp; \showcase{\frac{a+b}{c+d}} \\ \showcase{3\pi/4}     &amp; \showcase{\int_{0}^{1} x^{2} \,dx} \\ \showcase{x\in\Omega} &amp; \showcase{A \cup B \subseteq C \cap D} \end{tabular}   Which produces the output:    My minor quibbles are that:   The double '' seems to have been collapsed into a " I find mildly annoying the spaces after control sequences. I know why they are there, but could there be a way to remove the space if it is not followed by a letter or number? (Or, conversely, if followed by { or _)
99452
I'm quite happy hacking TeX macros and cobbling together bits and pieces from different style files to suit my own ends, but I have a suspicion that my resulting hacks are not quite as elegant as they could be.  In particular, with regard to when to expand and when not to expand macros.  A common occurrence for me is defining a meta-command that defines a whole slew of sub-commands.  So the names of the sub-commands will contain parameters depending on the parameter passed to the meta-command, and the contents of the sub-commands will also vary a little depending on what the meta-command got.  Often it won't be a direct substitution but rather a "if #1 is a do \this else do \that", but \this and \that need expansion at define time, not call time.  Here's a very simple example just involving direct substitution:  \def\cohtheory#1{ \expandafter\newcommand\expandafter{\csname #1func\endcsname}[1][*]{% \MakeUppercase{#1}^{##1}} }   Sometimes I worry that my commands are more complicated than they need be.  For example, if I want to call a command with two arguments and the arguments expand before the command, here's how I've coded it:  \expandafter   \expandafter   \expandafter   \command\expandafter             \expandafter             \expandafter               {\expandafter                 \argone                 \expandafter               }\expandafter               {\argtwo}   So I'm looking for guidance on when and how to control expansion in defining macros.  I strongly suspect that such cannot be given in a simple answer, so to make this a focussed question, let me phrase it thus:     Where's a good reference for writing TeX macros that includes advice on how to best deal with how to handle expansions?   Of course, if anyone can formulate some advice in short answer, I'd be only to happy to read it.  (Note: this was partially motivated by juannavarroperez's adaptation of my answer to  where over 20 \expandafters got condensed down to just 1!)
89836
I'd like to have an easy way to declare an operator that brackets its argument with a particular delimiter. As an example I'd like to be able to write  \Pr{X}   to mean the same as  \operatorname{Pr}\left[X\right]   FYI I know how to do  \newcommand{\Pr}[1]{\operatorname{Pr}\left[#1\right]}   but I thought I once saw a package that provided some command like  \DeclareBracketedOperator{\Pr}{Pr}{[}{]}   sort of a combination of \DeclarePairedDelimiter and \DeclareMathOperator and I think it also defined a starred version of the operator that didn't take any argument and didn't produce the delimiters.