# [texhax] \input{file} adds an extraneous space

Ulrike Fischer news3 at nililand.de
Tue Jan 3 11:31:31 CET 2012

Am Tue, 3 Jan 2012 01:53:57 -0800 (PST) schrieb
jtzzaa11-texhax2 at yahoo.com:

> After recently installing texlive , I've noticed that \input{file} adds an extraneous space, for example, if f.tex contains
> abc
>
> then
> \input{f}test
>
> produces
> abc test
>
> Here is a minimal example:
> \documentclass[10pt]{article}
> \begin{document}
> \input{f}test
> \end{document}
>
> Would appreciate suggestions how to solve this.

When TeX reads a file it adds \endlinechar at the end of each line.
Normally this gives a space. That's why

abc
cde

gives "abc cde" in a document and not "abccde".

TeX is doing this for every line of your main document and your
input file -- including the last line of this file.

You can suppress \endlinechar for all following lines by using
\endlinechar=-1. For the last line of your input file you can use
whatever you would use for the same purpose in single lines of your
main document: A "%", or a command which swallows the following
space like \relax or \endinput, or a command which swallows the
preceding space like \unskip.

--
Ulrike Fischer