I am trying to learn how to define commands (\newcommand) and variables (\def) in LaTeX.  When I try:  \def \new {$new$}   or  \newcommand{\new}{$new$}   and substitute it in the text:  \documentclass{article}  %\def \new {$new$}            %\newcommand{\new}{$new$}  \begin{document} lala \new lala \end{document}   The substituted text sticks to the following text as shown here:    no matter how many spaces I put after the command.   What causes this behavior and how can I change it?
5692
With a macro such as:  \def\naive{na\"{\i}ve}   I find that the space which I would hope to follow it, is absent. So, with  the \naive approach   I get     the naïveapproach   in the output. How do I bring back the space?
94237
I was trying to find how to pass some text to a file without overwriting what's there already using the > command and I realised I don't know what it's called. Searching for right arrow or right chevron or more than command didn't show up anything. I've always just called it pass to.
41313
I sometimes get annoying weird spaces in my latex and I dont know how to fix them. these are my global variables. I cannot paste my code unless someone tells me how I can convert all text into random characters. Using this template   \documentclass{article} \usepackage{spconf,amsmath,graphicx} \usepackage{tabu} \usepackage{subfig} \usepackage[usenames, dvipsnames]{color}   the texts that give error. I am not using any functions or local variables. They are all texts.  Many lines of text. LIDAR sensors that provide a 3D map of the environment around the vehicle are unequivocally more powerful than a single stereo-pair.  Despite these attractive features, the use of LIDAR sensors are still...  \begin{figure}[t]     \centering     \includegraphics[width=\columnwidth]{res}\\     \caption{The workflow of our object proposal algorithm.}     \label{fig:workflow} \end{figure}  Many lines of text. Here, we briefly review works that will be used as a baseline for comparison.  In the Selective Search (SS) algorithm \cite{selectivesearch}, pixels analyzed
46707
I need to define a token list of the form  \tl_new:N  \g_silly_tl \tl_set:Nn \g_silly_tl { Text ~ and ~ a ~ tie:?? }   How do I do this?    More generally, is there a reference where one can see how to input characters 'normally' under expl3 syntax?
109693
What is the difference between \text, \textrm, \textnormal, and \mbox (and possibly other commands commonly used to produce text in math mode)?  Various (La)TeX tutorials teach different methods, and I am sure that there is either a best one or there are subtly different usage scenarios.
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!
46706
With newcommand I can define customized command like \ABC. Is there any way to define a command with arguments. For example I want \brat{A}{B} be the same as [\![A,B]\!].
11450
I'm writing my bachelor-thesis and have a couple of small sub-sub-sections explaining conversions, like in the following  \subsubsection*{Assignment}  This document only explains non-compound assignments. The other kind, i.e \texttt{a += b}, is supported by the language too, but is not yet implemented.   \begin{itemize} \item If the first is an \texttt{auto} variable, no conversion takes place when assigning       the right hand side to the variable designated by the left hand side.  \item Otherwise, an assignment conversion takes place converting the given value to the type       of the designated variable.  \item Assignment requires an lvalue as the left hand side, and yields an lvalue result.  \end{itemize}  \subsubsection*{Multiplication} % ...   But latex renders it quite ugly with much space in between the items. I think it does so to fit the whole page. How can I tell it not to do so? Is what I'm doing right at all?
38541
I have a command like  \newcommand{\todo}[1]{#1}   which I sometimes replace by:  \newcommand{\todo}[1]{}   In terms of spacing/whitespace, the behavior of the "empty" command is as follows:  Test.  \todo{foo} % does not generate (vertical) whitespace =&gt; good  Test\todo{foo}. Test. % does not generate (horizontal) whitespace =&gt; good  Test\todo{foo}. \todo{foo} Test. % _does_ generate (horizontal) whitespace =&gt; bad   Is there any way to avoid this, i.e., to (temporarily) replace a command in a way so that it is fully equivalent to removing all occurrences of the command?  (I know that there are packages like todonotes or verbatim, which provide similar functionality. But I always wanted to know how to solve this manually, and never had an idea how to approach this / what to search for. Using \xspace or \empty in the command did not work at least.)
33623
I have a document where I quiet often refer to source code element, such as class names, I wanted to format these strings differently, but at the beginning I didn't want to fiddle with various options I had, rather I defined my custom command as follows:  \providecommand{\inlinecode}[1]{\texttt{#1}}   Now my question is, what do you think is the best way to define \inlinecode? Note: I often use text with unescaped &lt;, >, e.g., List&lt;T&gt;.   The \texttt looks fine to me, and works with &lt;, >, but sometimes the words overflow the line. Is there any way to tell latex not to overflow the line, but rather "underflow" or insert more spaces between words, which seems to me as (maybe still ugly but) more acceptable than overflow? And is it possible to achieve it by only changing definition of my command, so I won't have to change the whole source?
115624
Using the amsmath environment, I'd like to create a short-cut for  \begin{equation*}   \begin{split}     ...   \end{split} \end{equation*}   But saying  \newenvironment{eqs}   {\begin{equation*}\begin{split}}   {\end{split}\end{equation*}}   and using it with  \begin{eqs}   ... \end{eqs}   produces the error  ! LaTeX Error: \begin{split} on input line 67 ended by \end{eqs}.   However, using \newcommand works — but \eqs{...} over several lines looks a bit weird:  \newcommand{\eqs}[1]{   {\begin{equation*}\begin{split}{#1}\end{split}\end{equation*}}}  % ...  \eqs{   ...   ...}   Is it possible to get this to work with a new environment, or are there better ways to achieve something equivalent?
72828
Is there a way to use newcommand or some other nice technique to transform any occurence of  "bla"   in math mode into  \text{bla}   The reason I ask is because it is easy, and doesn't interrupt the flow of reading the (La)TeX code as much.  I would like to keep Xe(La)TeX's nice quote behavior (ie it can use the regular "" instead of backticks to quote some text outside math mode).
83510
I have been using LaTeX for a long time now, and I find myself often going to this website to solve my problems. This often includes copy pasting codes which include \newcommand, \newenvironment and \def. I think it is time I start to learn how to use them so I can solve my problems myself! It is always better if you actually know what is going on inside your code.  I am wondering if there is any turtorial or book out there that handles how to use those commands. Or is the best way to learn to just mess with a random file?   Thanks in advance!  (Also this is my first time I post here after using this website for so long, I really appreciate everyone who posts and tries to help other people here!)
41289
Lets say I have something like:   \[ Let x = number of cats \]   (This is a contrived example, but pretend we are actually inside a long align environment block...) "Let" and "number of cats" need to be written like normal text, while x= needs to be math type text.  I've seen this:  \[ \mbox{Let } x = \mbox{ number of cats} \]   and this:  \[ \textrm{Let } x = \textrm{ number of cats} \]   They seem to produce equivalent output, but I'm not sure which is the "correct" one. Also, they are not ideal in that the extra space needs to be placed inside the text mode block, otherwise it is ignored as math mode and butts the text right up against the math.  Ideally there would be some command which allowed embedding text into an equation, which correctly inserted leading and trailing space around the block as required without adding space inside the text block.  How does one do that "correctly"?
21438
In  we learned how to use \newcommand within a command definition with another \newcommand, when the name of the inner command needs to contain a parameter of the outer command. Now, suppose I want to do the same, but for the inner \newcommand to also have parameters, i.e. I want the following code to work:  \newcommand{\defsilly}[1]{%   % define a command named silly#1 , taking a single parameter } \defsilly{willy} \sillywilly{theparameter}   Motivation: I'm writing a thesis document class, which has a bunch of the following kind of command pairs:  \newcommand{\iitthesis@authorEnglish}{Name of Author} \newcommand{\authorEnglish}[1]{\renewcommand{\iitthesis@authorEnglish}{#1}}   I want to replace each of these pairs with something like:  \iitthesis@thesisdatafield{authorEnglish}{Name of Author}   This defines both the above commands.
112224
Do you know how LaTeX implements environments? To be more precise, what does  \newenvironment{&lt;env-name&gt;}[&lt;n-args&gt;][&lt;default&gt;]{&lt;begin-code&gt;}{&lt;end-code&gt;}   in terms of TeX commands (i.e., how is the LaTeX command \newenvironment defined in TeX)?
86513
In order to separate the content structure from the style, I decided to implement commands for denoting random variables:  \newcommand{\myrv}[1]{\mathbf{#1}} \newcommand{\rvA}{\myrv{A}} \newcommand{\rvB}{\myrv{B}} \newcommand{\rvC}{\myrv{C}} ...   This way, if I ever decide to change the style of random variables from \mathbf to say \mathbb, all I need to do is to change the definition of \myrv. Is a way to generate the commands \rvA, \rvB, \rvC, ... automatically?