It seems that \input appends a trailing space.  MWE:  foo.tex  \documentclass{article}                                                          \begin{document} foo\input{bar.txt}baz \end{document}   bar.txt  bar   Which, using pdflatex foo gives the output foobar baz, with a space in between.  How do I remove it?
76807
Intro  I'm working on a lightweight package that allows you to put any content (typically LaTeX code) in an environment, then use that content multiple times, each time scanned separately, so you can use it both as verbatim output and interpreted as LaTeX.  Its main purpose is to typeset LaTeX code and its 'result' side-by-side; useful for documenting TeX packages without having to copy/paste code. But it has other purposes as well.  After experimenting with \scantokens until I gave up in tears, I arrived at the filecontents environment, which almost solved my problem singlehandedly!  The Problem  The problem is, when reintroducing filecontented code through \input, LaTeX adds an implicit newline at the end, which translates to whitespace that I can't seem to get rid of.  I've seen many semi-related questions floating around, with answers employing techniques like:   reading a file line-by-line, using \everyeof in some clever way, playing with \endlinechar or using packages such as catchfile   but none of them provides a clear answer to the following question:  The Question  How can I \input a file without getting the implicit newline?  Minimal Working Example  \documentclass[margin=1mm]{standalone}  \usepackage{filecontents}  \begin{filecontents*}{tmp.tex}     \LaTeX{}\end{filecontents*}  \begin{document}     \fbox{\input{tmp.tex}} \end{document}     Note the extra whitespace to the right of the box.  Note also that I'm definitely not adding any explicit whitespace. Even a manually produced file (so, not using filecontents) with no newlines at all exhibits the same problem.
63322
I a chat discussion it was suggested that \hspace*{\fill} (with a space before it to allow for a line break) was sufficient to always get the text following aligned to the right. And indeed, it is aligned to the right.    However, in one case it is inserting an additional line  break where one should not be required as illustrated by the last example here.  I want the text bumped to the next line if and only if (iff ) there is no room:    If I remove the space before the \hspace*{\fill}, there are cases (second and third) where a new line should have been inserted but is not:    Related Question:      I have tried the suggestions at the related question and:   Martin Scharrer's suggestion of using \hbox{}\hfill results in the text being on the left for the last case. Herbert's \When macro exhibits a similar problem for the last case. Thorsten Donig's \signed macro does yield the correct number of lines, but portions of the file name for the middle two cases show up on the second line when they easily fit in the first line.     Notes:  I believe that this is unrelated to the problem, as I was able to reproduce the problem without it.  But, am mentioning it here in case it causes an issue with the proposed solution.  I am using \texttt for the file name. This resulted in an additional complication which I initially thought was the cause of the problem.  So, my actual use case is commented out below and it incorporates a solution from        Code:  \documentclass{article} \usepackage[paperwidth=7.0cm,showframe]{geometry} \usepackage{xcolor} \usepackage{xparse}   \newcommand*{\FillLine}[2]{% \noindent\parbox{\linewidth}{%     \raggedright     File:~#2 % &lt;-- Need space here     %Space before \hspace* allows for a break before it     \hspace*{\fill}\texttt{\small CONFIDENTIAL}%  }% }  %\newcommand*{\EnableHyphenationInTexttt}{\hyphenchar\font=45\relax} % %\newcommand*{\FillLine}[2]{% %    \noindent\parbox{\linewidth}{% %       \raggedright %       File:~\texttt{\EnableHyphenationInTexttt#2} % &lt;-- Need space here %       %Space before \hspace* allows for a break before it %       \hspace*{\fill}\texttt{\small CONFIDENTIAL}%  %    }% %}  \begin{document} \FillLine{Name}{Value}  \bigskip \FillLine{Name}{A-Long-Value}  \bigskip \FillLine{Name}{iiiiiii-iiiii-iiiiiii}  \bigskip \FillLine{Name}{Some-Really-Really-Long-Value} \end{document}
120813
I asked  how to make cd protect spaces. Tab completion is great, but sometimes you paste the path from the clipboard so this is useful.  The solution breaks with parentheses however. No matter how you try to escape and protect the input it always returns:  bash: syntax error near unexpected token `('   Is there some way to have it also deal with parentheses? What I want is that when I enter this, it works:  cd My path with spaces (and parentheses)
90655
I'm coding a TeX file and although the .pdf is correctly rendered, I'm using "stone age" tools to code it. As some examples, I use \\ to leave a line space between two paragraphs, or \noindent in every paragraph I start. Basically, I'm just using the basic TeX data I have to code a paper, but I'm sure there are things that can be replaced with much better and appropriate codes, since I get badness 10000. This is the console:  *geometry* detected driver: pdftex ("C:\Archivos de programa\MiKTeX 2.9\tex\latex\amsfonts\umsa.fd") ("C:\Archivos de programa\MiKTeX 2.9\tex\latex\amsfonts\umsb.fd") Underfull \hbox (badness 10000) in paragraph at lines 10--11 [1{C:/Documents and Settings/All Users/Datos de programa/MiKTeX/2.9/pdftex/conf ig/pdftex.map}] Overfull \hbox (10.8009pt too wide) detected at line 49 \OML/cmm/m/it/14.4  [] \OT1/cmr/m/n/14.4 + 1 = [] [] \OML/cmm/m/it/14.4 x \OT1 /cmr/m/n/14.4 + [] [] \OML/cmm/m/it/14.4 x [2] Overfull \hbox (26.66542pt too wide) in alignment at lines 80--82  [][][] [] [3] Overfull \hbox (23.60692pt too wide) detected at line 90 \OML/cmm/m/it/14.4  [] \OMS/cmsy/m/n/14.4 &gt;&lt;C:/Archivos de programa/MiKTeX 2 .9/fonts/type1/public/amsfonts/symbols/msbm10.pfb&gt;   How could I clean up these errors, which I'm guessing are basic?
28603
I'd like to, first thing before writing anything on a page, add some vertical space.  Minimal (non)working example:  \documentclass{article} \begin{document}  \vspace{250px} I want to be further down on the page :(  \vspace{250px} Haha! Sucker :D \end{document}     How can I get the first \vspace to work, just like the second one?
118840
I hope this question is in order here although it rather asks for a "best practice" than for some "solution".  I am wondering to what extent blank/empty lines in the code (I am using pdflatex) should be avoided and e.g. be replaced by %. My source code is full of single blank lines e.g. before the start of a new section, between math/text environments in order to increase the readability of the code.  Are such blank lines going to be ignored anyway (I guess this might depend on the specific instance?)/only cause minor vertical space in the PDF, or are they deemed "bad practice" and should be avoided?  All I could find was  according to which - I take it - blank lines should mostly be avoided apart from before tabular and array environments.
105350
I'm writing a paragraph mix with Chinese characters and English characters, I found space between them. The space is especially huge when use \ttfamily. How can I remove those space?  Chinese中文english  Chinese中文{\ttfamily english}中文  \ \ \ remove this ↑   The pdf file looks like this:
72059
Within a custom command, I'm doing the following to write to a file:  \newcommand\mycommand[1]{   \newwrite\file   \immediate\openout\file=foobar.tex   \immediate\write\file{     foo     bar     #1     blarg   }   \immediate\closeout\file }   Of course when I invoke it as \mycommand{baz}, I get the following contents in foobar.tex:  foo bar baz blarg   with all new lines turned into spaces by LaTeX. My question is, is there a way to output these lines into the file "as expected", i.e. with real new lines at the end of each line instead of a space? I'm thinking some \catcode wizardry should do the trick, but I'm not sure which character I need to redefine and to what category code.  Update  The solution in  works perfectly. The only problem is when #1 contains embedded newlines. I can of course send it to mycommand with its own slew of ^^J, I was wondering if there is a way to avoid this.
36955
Consider the following m(non-)we:  \documentclass{standalone} \begin{document} Foo &amp; Bar \end{document}   The build will fail with  ! Misplaced alignment tab character &amp;.   while it will generate a perfectly fine PDF when removing the &amp; character from the code.  Even plain TeX behaves like that and  Foo &amp; Bar \bye   yields the same error.  I have only ever seen &amp; used in tabular and array environments, never outside of it. Why is that?  Couldn't one define e.g. \tabular and \endtabular so that &amp; is only special inside the environment, and just a normal character outside of these environments?  Why does &amp; outside of tabular and array environments have to break the document?  To rephrase the question: WTF is an alignment tab character and where do we usually put it?
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.
104261
I'd like to modify the \int command such that it adds an automatic negative space, e.g. \! after the integral sign. Preferentially, I'd like to be able to not edit any of my code, so cleverly redefining \int seems like my best option. Unfortunately, naive implementations get the limits wrong:  \documentclass{article} \usepackage[intlimits]{amsmath} \usepackage{ifthen}  \newcommand{\diff}[2][]{   \ifthenelse { \equal {#1} {} }   {\ensuremath{\mathop{\mathrm{d} #2}}}   {\ensuremath{\mathop{\mathrm{d}^#1 #2}}} }  \begin{document}  This is what I would want: \begin{equation}  \int_0^\infty \mspace{-4mu}\diff[3]{\boldsymbol r} f(\boldsymbol r), \end{equation} but with this ``user code", containing no negative spacing explicitly: \begin{verbatim}  \int_0^\infty \diff[3]{\boldsymbol r} f(\boldsymbol r), \end{verbatim} which for comparison with the above gives: \begin{equation} \int_0^\infty \diff[3]{\boldsymbol r} f(\boldsymbol r), \end{equation}  mostly because this gives me the option to remove it or change the spacing when I see fit. \end{document}   Which results in:
39060
Whenever I try to insert " or ' I have to validate it by space, otherwise strange things happen as with ' followed by an a becomes áinstead of just 'a, similar behaviour with double quotes. I find this annoying and want to disable it. How do I do that?
93586
These should work by adding spaces or removing spaces from the beginning of the current line or every line between the start and end of a text selection (inclusive).  (edited this question to supplement )
8043
Is there a clean, preferably standard method of trimming leading and trailing whitespace from a string in C? I'd roll my own, but I would think this is a common problem with an equally common solution.
464
I want to import graphics into my main input file using the macro \includegraphics. It does not work if the filename contains spaces.   also discusses this subject, but there is no solution there.  My compilation routine is latex->dvips->ps2pdf (because of PSTricks).
51183
In the following example, the space after the red equation is much larger than the space after the black one.  \documentclass[12pt]{article} \usepackage{xcolor} \begin{document} \[ a = b \]  The quick brown fox jumps over the lazy dog. \color{red} \[ a = b \] \color{black}  The quick brown fox jumps over the lazy dog. \end{document}   It appears to me that the presence of \color{black} fools TeX into thinking there is something on the line after the equation, so the paragraph break causes a spurious blank line before the text. Section 3.7 of  mentions spacing problems, but doesn't really explain the situation. What is on the line after the red equation?  Note that there is already ; I want to understand what is going on.
35886
Code is supposed to be exact and "as-is". Sometimes, showing two spaces is important. In a comment, it is not possible to show code with  multiple   spaces. This became apparent in  (see comments).  EDIT: apparently this bug is larger then I thought: multiple    spaces   here are neither preserved in normal question text. Pity (though I couldn't find this reported before, I'd assume it is).  Workaround: use Alt+0160 (windows), or U+00A0 (Unicode NBSP), as I did in the example above.