Comments & Wishes\input is not equivalent to typing

General comments, feature, category or forum wishes for this LaTeX community
Post Reply
pireddag
Posts: 28
Joined: Tue Nov 21, 2017 3:06 am

\input is not equivalent to typing

Post by pireddag »

I have just read https://tex.stackexchange.com/questions ... e-the-file

It shows that \input is not equivalent to typing (https://tex.stackexchange.com/questions ... vs-include says that it is equivalent).

Would it be interesting to make the input command equivalent to typing? If any of the LaTeX3 team is listening in this forum, could this be part of the new system?

As far as I understand, it works in this way because of the way TeX works (expansion). But it would make sense to make it work in another way :-)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
User avatar
Stefan Kottwitz
Site Admin
Posts: 10270
Joined: Mon Mar 10, 2008 9:44 pm

\input is not equivalent to typing

Post by Stefan Kottwitz »

Hi Giovanni!

In normal use \input is equivalent to typing. Indeed, there are exceptions, rare cases, and they are unusual, such as that case - using \input within a macro or an environment definition gives the question, does it have to be interpreted at definition time (only that time once) or each time the macro (or environment) runs when the whole document is translated.

I would use \input in a sane way, to externalize code parts, but not fragements of code parts within definitions. So I would not use \input within a number, in an argument, or within a command name. That goes too far. Here, \input relies on the outside context, and expansion time.

That question is interesting, but if we stay practical, introducing a new \input that covers extreme situations would not be very efficient, as not many people might use it, I guess. But the standard \input is handy in normal life for everybody.

Stefan
LaTeX.org admin
pireddag
Posts: 28
Joined: Tue Nov 21, 2017 3:06 am

\input is not equivalent to typing

Post by pireddag »

Stefan Kottwitz wrote:Hi Giovanni!

In normal use \input is equivalent to typing. Indeed, there are exceptions, rare cases, and they are unusual, such as that case - using \input within a macro or an environment definition gives the question, does it have to be interpreted at definition time (only that time once) or each time the macro (or environment) runs when the whole document is translated.

I would use \input in a sane way, to externalize code parts, but not fragements of code parts within definitions. So I would not use \input within a number, in an argument, or within a command name. That goes too far. Here, \input relies on the outside context, and expansion time.

Stefan
This is reasonable. However, it raises a second point, which is important in my opinion. The clarity of the documentation of LaTeX can be improved ; I say it from my point of view - I have used LaTeX with a superficial knowledge of it for about 15 years and the documentation is not satisfactory for me.

In this case, the correct statement (different from the one that appeared on StackExchange) is

\input is expanded to the content of the file, and this in normal cases is equivalent to typing.

For example in https://en.wikibooks.org/wiki/LaTeX/Mod ... vs_include
I read:

"When the compiler processes your base file and reaches one of the commands \input or \include, it reads filename.tex and processes its content in accordance with the formatting commands specified in the base file"

(it is talking about the commands \input{filename} and \include{filename})

while the correct statement - as far as I understand - is "When the compiler expands the command \input ".

The complaint on the documentation is however more general ;-)
User avatar
Stefan Kottwitz
Site Admin
Posts: 10270
Joined: Mon Mar 10, 2008 9:44 pm

\input is not equivalent to typing

Post by Stefan Kottwitz »

it's not really LaTeX documentation, it's just a Wikibook that's not written by the LaTeX team. I guess anybody could edit it.

Stefan
LaTeX.org admin
pireddag
Posts: 28
Joined: Tue Nov 21, 2017 3:06 am

\input is not equivalent to typing

Post by pireddag »

Stefan Kottwitz wrote:it's not really LaTeX documentation, it's just a Wikibook that's not written by the LaTeX team. I guess anybody could edit it.

Stefan

You caught me there :-)

On my statement that the LaTeX documentation is not satisfactory though I am insisting. I even have an authoritative source: Christian Feuersänger.
Have a look at this:
https://archive.ins.uni-bonn.de/wissrec ... ferenz.pdf
He says in the abstract

"Dieses Dokument entstand über mehrere Jahre, in denen ich das Resultat von zum Teil stundenlangem Suchen nach LATEX-Einstellung gesammelt habe"

I do not need to translate it for you, but for people that do not know German: "I composed this document over many years, collecting the results of my searches, that sometimes took hours, for LaTeX settings."

Even if he did not mean it in the way that I mean, I think I am reporting it in a fair way: a person with a university degree in Computer Science, and expert in TeX and LaTeX, needs many years to collect information on LaTeX settings. I think that this can and should be improved.

For the \input command: Source2ε refers to TeX, and in the TeXBook there is a single line that explains it as far as I could see (I am not aware of an official TeX reference manual).
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

\input is not equivalent to typing

Post by Johannes_B »

https://chat.stackexchange.com/transcri ... 4#47473464

Look at the few messages above.


The TeXbook is the official user guide of TeX and the plain format. But you could also have a look at tex.web. it is the documented source.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
pireddag
Posts: 28
Joined: Tue Nov 21, 2017 3:06 am

\input is not equivalent to typing

Post by pireddag »

Johannes_B wrote:https://chat.stackexchange.com/transcript/41?m=47473464#47473464

Look at the few messages above.
Thanks, it is helpful (it will take a bit of time before I can parse it completely). Of course it is also an information that would belong nicely to a good LaTeX documentation.
Post Reply