# Why should some TeX primitives never be set directly in LaTeX?

In an earlier question More economic and robust command for abstract at the beginning of chapters, David Carlisle told that one should never use directly some TeX primitives. How can I distinguish which primitives are safe to use?

-
Well, it depends on what primitive: \hfill is a TeX primitive, but it's surely allowed for use in LaTeX documents. –  egreg Apr 5 at 11:57
I assume you refer to tex.stackexchange.com/questions/169719/…? Please focus the question on the specific primitives raised there. –  Joseph Wright Apr 5 at 12:03

well I didn't say any primitives, but those in particular (\leftskip and \rightskip) are bad ones to touch..
LaTeX list environments (which is almost all latex display environments, so not just enumerate but center, verbatim, quote etc) all need to know how much space is available on the line after current indentation levels are taken into account. LaTeX has several parameters that must be updated together, \leftmargin, \linewidth, \@totalleftmargin, \textwidth, \hsize are supposed to fit. If you change \leftskip without changing the entire LaTeX parameter structure then LaTeX won't "know" that you have indented stuff and all such environments will base their layout on the settings they think are in effect which may look OK or terrible depending on the exact circumstances, but if it looks OK it's by luck not design:-)
If I understand well your answer, if one uses a primitive modifying the layout of the page, then one has to modify accordingly all the parameters of the layout? And for this reason, but not because they are primitives, I should not use \leftskip and \rightskip? –  Lionel Darondeau Apr 5 at 12:40
As long as the environments you mention are not used, and the scope of the change to \leftskip and \rightskip is limited, there is thus no reason to restrain oneself: indeed the default \l@section and \@dottedtocline do not update neither \leftmargin nor \linewidth nor \@totalleftmargin nor \textwidth nor \hsize. I am pointing that out because many examples in the etoc manual manipulate \leftskip, \rightskip and \parfillskip to define the toc line styles, and people reading your answer might become very suspicious that this is dangerous. –  jfbu Apr 5 at 12:55
@DavidCarlisle somehow, this is a comforting thought :-) –  jfbu Apr 5 at 15:31