Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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
1  
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

1 Answer 1

up vote 12 down vote accepted

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:-)

share|improve this answer
    
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
    
@jfbu it is dangerous to play with fire but lots of people still like fireworks:-) –  David Carlisle Apr 5 at 13:13
2  
@LionelDarondeau yes all latex commands end up using the primitives eventually so clearly if you emulate enough of their definition it is equivalent to using the higher level commands, but it's like dropping to machine assembly code from a high level language, it might give you a slight efficiency gain, but it might just crash the system and either way it's a maintenance pain going forward. –  David Carlisle Apr 5 at 13:16
    
@DavidCarlisle somehow, this is a comforting thought :-) –  jfbu Apr 5 at 15:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.