I've made a function/command for use mid-sentence, but it adds spaces everywhere it's inserted. Is there a way to flag it so it doesn't make them?  Code:  \def \testvar{0} \newcommand{\test} {     \ifnum \testvar=1 {         test0     }     \else {         test1     } }   Inside document:  aaaa \test aaaa   Output:  aaaa    test1  aaaa   Wanted output:  aaaa test1 aaaa
2826
I see that the code in many packages and examples contains percent signs % at the end of (many) lines. What are they used for? Do they affect the parsing of those lines?
105270
After trying both commands, I noticed that \hspace* opposite to \hspace will insert a space over the end of the line.  So I was wondering if someone could explain how that works and also when to use either command.
33327
vi treats dash - and space &nbsp; as word separators for commands such as dw and cw.  Is there a way to add underscore _ as well?  I quite often want to change part of a variable name containing underscores, such as changing src_branch to dest_branch. I end up counting characters and using s (like 3sdest), but it would be much easier to use cw (like cwdest).
65398
I have a macro which appears throughout my document in various places:  \newcommand{\placefraction}[2]{     $\frac{#1}{#2}$ }   Sometimes it is placed with regular text. Sometimes it is placed within other math modes. However, the document won't compile if it is placed inside another math mode.  None of my math ever appears in displayed formulas, it is always part of the paragraph.   How can I have a macro which sometimes appears inside math mode, sometimes outside, but itself contains math mode?
15755
Tried to add a comment to a post today, which ended up looking rather weird. What I had typed was:  On windows I believe you need to use `\` instead of `/`   As you can see in the first comment to this question, I don't exactly end up with what I thought I would... What's going on here?  Tried various combinations of double \\ and double `` (which seems to be impossible to have in an inline code thing...?), but couldn't get a good result. Ended up putting a space after the slash, which at least made it readable. Problem then was that the space between the inline code and the word "instead" seems to disappear O.o
579
I have defined my own language whose syntax is very close to the one of Pascal. I would like to type the following program for instance. Many people use the packages algorithmicx or algorithm2e to print programs, but it seems that we have to use their specific keywords of its syntax like procedure, end while.  I just want to indent spaces when needed, and bold some words when I want (sorry that I could not bold letters in the following figure). Do I have to use  texttt for each line? Also, with verbatim, I could not bold words...  Also, as the program is not large, I would need to put it on the left side of the page, and leave space for some explanasion text on its right hand side. So I  guss I need to get them all together, and use multicols.  Could anyone help?  program test                                      some text here var   i : integer;                                    ...    b : boolean; begin    i := 1;                                        ...    b := true;    while i &lt; 15 do       i := i  + 1;       b := not b                                  some text here    od end   Edit1: Following @Werner's tabbing solution, I have made the code a minipage:  \begin{minipage}[t]{0.48\linewidth}% \begin{tabbing} Werner's solution \end{tabbing} \end{minipage}\hfill \begin{minipage}[t]{0.48\linewidth} a paragraph \end{minipage}   Actually as the code shows, I want the texts to be another separated minipage on the right hand side of the code. I have then 2 questions:   is it reasonable to make 0.48\linewidth instead of 0.5\linewidth? 0.48\linewidth is a conventional choice? is it possible to make a frame around the code, and use \caption and \label to make it a reference (I prefer figures)?
45020
The following code works, although I have a feeling my \settowidth method of discarding the output is not how it should be done:  \documentclass{article} \newlength{\trashlength} \long\def\ignoreoutput#1{%  \settowidth{\trashlength}{#1}% } \long\def\command#1{  This \gdef\stuff{Stored: #1} shouldn't be here. } %% Should not raise Missing \begin{document} error here: %\ignoreoutput{\command} \begin{document}  % Should produce "nothing":  no\ignoreoutput{\command{Side %\par %%%%% this breaks everything.    effect!}}thing.   % Should output the text previously stored:  \ifx\stuff\undefined No side effect.  \else \stuff \fi \end{document}  When uncommenting the \par though, it breaks: with Paragraph ended before \@settodim was complete.  So how do I ignore commands that allow long input?
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.)
117474
By default, (La)TeX adds extra space between sentences. The exact rules are in the TeXbook, a summary by TH. can be found . What follows is is my "executive summary":   After any period (or quotation/exclamation mark) that doesn't follow a capital letter, TeX adds a font's "extra space" to the "normal (interword) space". For Computer Modern 10pt, the normal space is 3.33pt and the extra space 1.11pt, resulting in an intersentence space of 4.44pt (+33% compared to the nomal space, assuming no stretch and shrink). A sentence end after a capital letter is indicated by the \@ command: Ann is learning the ABC\@. To denote that a period after a lowercase letter doesn't end a sentence, one may use \@ as well as an explicit space: Prof.\@ Higgins or Prof.\ Higgins.   Intersentence spacing may be brought in line with normal spacing by issuing the \frenchspacing command. (This is the standard setting for certain languages, e.g. the  (n)german option of the babel package.) With \frenchspacing enabled, there's no need to use the \@ command. One may revert to (La)TeX's default behavour by issuing \nonfrenchspacing.  So, there's the choice between extra intersentence spacing and uniform spacing. What is missing in my opinion is a third option I'll call "tightened frenchspacing": normal (interword) spacing between sentences and decreased spacing after non-sentence ending periods. To be somewhat more precise (while still ignoring stretch and shrink), I envision the following:   Adhering to a font's ratio between "normal space" and "normal space plus extra space" (3:4 for Computer Modern), the intersentence space is set to the normal space. The space after non-sentence ending periods equals the normal space multiplied by the above ratio (resulting in a space of 2.5pt for Computer Modern). As with \nonfrenchspacing in effect, the \@ command is used to denote cases of special punctuation.   How should such a "tightened frenchspacing" option be implemented?  EDIT: Thanks to Mico for providing what may well be a stepping stone to a solution. Here's another attempt at clarification:   Simply reducing the spacing after any period is not what I had in mind. There should be a (tangible) difference between end-of sentence spaces and spaces after non-sentence-ending periods (only that the latter should be reduced instead the former augmented). If adhering to a font's normal space/extra space ratio is not possible, a solution that adds a fixed (reduced) space (say, a thin space) after non-sentence-ending periods will be accepted. For compatibility reasons, I'd prefer a solution that works with the traditional use of \@ (i.e allows "tightened frenchspacing" for existing documents without the need to change the document body). Should it turn out that a different set of "special punctuation" macros is needed, I'll accept this as a solution.
51349
Can I safely omit quotes on the right side of a local assignment?  function foo {     local myvar=${bar}     stuff() }   I'm mainly interested in bash, but any info on corner cases in other shells are welcome.
37903
In math mode, LaTeX inserts a small space after a comma. This looks nice in $a,b,c$, for example. But I don't like the way it looks when using a comma as a thousands separator, e.g., $x = 100,000$. (There is no space after the comma when writing 100,000 outside of math mode.) Is there an easy way to avoid this? Some symbol I should be using instead of comma?
7661
Have anyone an idea how i can use \IfFileExist{}{}{} for file names with spaces?  f.e. didn't work  \newcommand{\runI}{D:/Test/run1 - T2} \newcommand\IG[2][]{\IfFileExists{#2}{\includegraphics[#1]{#2}}{\fbox{File #2 doesn't exist}}}  \begin{figure}[htbp] \centering \IG[trim = 40mm 10mm 40mm 2mm,clip = true, width=0.4\textwidth]{\runI/LatexTestFig2.png} \caption{run 1} \label{overflow} \end{figure}   f.e. work  \newcommand{\runII}{D:/Test/run1-T2-Kopie} \newcommand\IG[2][]{\IfFileExists{#2}{\includegraphics[#1]{#2}}{\fbox{File #2 doesn't exist}}}  \begin{figure}[htbp] \centering \IG[trim = 40mm 10mm 40mm 2mm,clip = true, width=0.4\textwidth]{\runII/LatexTestFig2.png} \caption{run 1} \label{overflow} \end{figure}   what can I do? THX
106890
Attention I have already a possible answer and will add it soon. I thought it would be useful to have a solution about it on the site. (Other answers are naturally welcome too).  Question How to activate or suppress the french spacing before some punctuations like a colon in the text argument of \href locally (for one specific \href) and globally? Switching the language is not an answer!  Minimal examples for tests (the argument of \href should normally be a valid url, so it is a bit unfair to add an example without a colon in the link):  pdflatex  With pdflatex it depends on the link how the argument of \href is printed:  \documentclass{article} \usepackage[french]{babel}  \usepackage{hyperref}  \begin{document} With pdflatex no french spacing in links with colons:   \href{link}{a:b}  \href{link:colon}{a:b}  \end{document}     lualatex  With lualatex the spaces are always there:  \documentclass{article} \usepackage[french]{babel}  \usepackage{hyperref}  \begin{document} With lualatex always spaces:  \href{link}{a:b}  \href{link:colon}{a:b}  \end{document}
26731
I tend to use \newcommand to define macros for symbols I use often, e.g. \newcommand{\hankel}{H^{(1)}_0}.  One inconvenience of this approach is the fact that command names cannot include numbers.  What I ideally want is to map something like \H0 to H^{(1)}_0.  I imagine this could be done with some macro expansion/snippet package, or one might use \newcommand to define a command that takes a parameter, etc.  Before I start experimenting, though -- is there a canonical way of dealing with this problem?
73407
How can I define my own shorthand command, but making sure that the spacing afterwards is correct?  \newcommand{\abc}{\textsc{abc}} produces 'ABC,' but has the problem 'ABCmoretexthere' (i.e. no space before the next word).  Vice versa  \newcommand{\abc}{\textsc{abc} } produces  'ABC moretexthere' but has the problem 'ABC ,' (i.e. one space before the comma).  How can I make both work?
95676
I want to typeset the following in TeX (without the arguments).     &lt; , >   I know that I can accomplish this by doing \langle , \rangle  As an example I want to write something like the follwing:     ...The adjoints are with respect to the ( \langle , \rangle ) and not with respect to ( ( , ) )   But spacing on either side of the comma inside \langle \rangle does not look right.  How does one fix this? Thanks.
75612
So, in one of my recent Code Review questions, I have a function $$ and posting it (even inside the code block) causes the following issue.  So you can see that my code looks like the following:    but then in the post:    All the space between the two dollar dollar blocks is seemingly replaced with a series of numbers, a key perhaps. (I blurred it out, just in case)