4

This question is quite general. Nonetheless I believe that it touches upon something fundamental. That said, anyone feel free to improve the question.

LaTeX can be thought of as a complex algorithm that does everything without manual fine-tuning. In most cases, one needs to run LaTeX just twice, which is remarkable given that it is a linear compilation process. However LaTeX's design also leads to the disadvantage that certain types of fine-tuning which conceptually really are best done during a post-compilation phase are not easily done with LaTeX.

An example: say I would like to remove the page numbers of all pages with a figure at the top of the page. (If you can think of a better example, feel free to improve the question.) What are ways in LaTeX to make such post-compilation changes easiest? (The idea is that the user can supply additional data after "compilation proper", and one would then run a post-compiler that does some minor fine-tuning.)

I understand that the right answer wouldn't be "a single LaTeX command". Instead, answers might point to (La)TeX derivatives, constructions or tricks on top of the standard LaTeX engine, or conceptual pointers. (And, yes, of course solving this problem will require one additional compilation pass at the end, either directly by LaTeX or by something else. I suppose one could do the initial compilation phase(s) by "something else" and the final run by LaTeX proper. This is an open question, and creativity is welcome.)

  • 1
    Actually, the example you gave would be best done within LaTeX. Only LaTeX knows if the thing at the top of the page is actually a figure, and it should be possible to make LaTeX remove page numbers in this case. Can you think of other examples? – krlmlr Dec 30 '12 at 11:26
  • @user946850 Thanks for your comment. 1. This might be true in principle (I don't know how easy this is, though), but it's also an example of something that is very easily done by a user in one quick pass. See also my clarification about user input. 2. There are some styleguides with prescriptions such as "no more than three consecutive line-final hyphens". While I find the prescription a bit weird, it would be nice to have an easy way to modify single pages post-compilation while keeping all other pages the same. – Lover of Structure Dec 30 '12 at 11:35
  • @LoverofStructure ... the three hyphens issue might be mathematically intractable - in some cases. Consider a fully stretch page that such a decision will add an extra line. If you have constrained your system for flush bottom pages you need to relax a constraint... or modify the following pages etc. – yannisl Dec 30 '12 at 12:01
  • @YiannisLazarides I enjoy this discussion, as it helps us converge towards what might be needed. I think a way for the user to specify first which part of the text he would like to fiddle with (all the rest would have to remain constant during adjustment-compilation) before indicating desired adjustments might be really good. – Lover of Structure Dec 30 '12 at 12:12
  • @YiannisLazarides Btw, even the simple hyphenation+justified combination is impossible to solve if the paragraph contains too many difficult-to-hyphenate words. Anyways, if it's mathematically difficult, that's probably a case for letting the user select a region he'd like to modify and then let him override things. – Lover of Structure Dec 30 '12 at 12:52
  • @LoverofStructure: The requirement to keep all other pages the same is a hard one. However, in most cases, changing page n doesn't affect pages 1 to n-1. Why don't you make your fine tuning in the LaTeX source (along with a special formatting so that these hacks can be easily identified and/or removed later)? Add version control, and there is your post-compilation! – krlmlr Dec 30 '12 at 14:05
  • @user946850 Something like that, except what you propose is very high-level. The idea was that there might be an easiest way to create such infrastructure, with a package perhaps, if somebody hasn't already done that. – Lover of Structure Dec 31 '12 at 05:02
  • @LoverofStructure: What's so high-level about a manual \thispagestyle{emtpy} hack? What kind of infrastructure do you have in mind, what should the package you mention do? – krlmlr Dec 31 '12 at 14:07
  • @user946850 I do not know what you mean by a "\thispagestyle{emtpy} hack". // An infrastructure could be a way to select a block of code, with LaTeX giving one the opportunity to override (for a post-compilation step) the output generated by that piece of code; that is the post-compiler will guarantee to keep the output of all code outside of that block identical. This is just one idea, there might be many others. – Lover of Structure Jan 01 '13 at 01:47
  • 1
    @LoverofStructure: \thispagestyle{empty} selects an "empty" page style, without page numbers, for the current page -- just as in your example. Guaranteeing the same output is difficult, but it might be possible to write code that checks the visual representation of a page and warns if there are changes. Perhaps the answers to this question help: http://tex.stackexchange.com/questions/55243/strategies-for-corrections-in-book-typeset-with-tex – krlmlr Jan 01 '13 at 08:40
  • @user946850 Thank you, that link is very relevant. This also gives me the idea that a package providing something like a generalized \vphantom-overlap macro that works for arbitrary multi-page content (what I select might start in the middle of one subsection and end in the middle of a section in the next chapter) could be very useful: it'd reserve the space needed by original text but lets me typeset other stuff into that space. I'm not sure how practical this would be in the end, but for the question you linked to, it would likely have solved the OP's problem. – Lover of Structure Jan 01 '13 at 11:28
  • @user946850 As for the version control you mentioned: setting that up so that text marked up in exactly a certain way in the text source would automatically be commented out later (which would be better than just discarding those changes!) will not be straightforward. Or having some sort of macro/timestamp system that compiles a particular piece of code only if the file hasn't been modified before that macro (code-wise) or after that macro was generated (time-wise). I'm not saying it's easy to come up with a system that isn't messy to use, but it might be useful if someone explored this issue. – Lover of Structure Jan 01 '13 at 11:35

1 Answers1

6

It is said that George Bernard Shaw would examine galley proofs of his work and recast sentences, or even whole pages, in order to avoid unsightly word breaks, excessive white space caused by justification, and other typographical difficulties. Of course, he was published at a time when typesetters were sent to the block for committing the abominations above.

Neither an automated system nor a manual system can manage to resolve all the aspects and details of a complex creation such as a book. All those beautiful three column or four column publications with a perfect article fitting exactly on one or two pages has been manually edited to add or remove content, adjust images and the like.

Your example, and maybe is a bad one, captures the essence of the problem well. You want to fix the issue after the compilation of the document; but the problem was created by leaving such a presentational decision after the Class Definition stage whereas it should have been included during the Class Definition stage.

Therefore to answer your question what one could do to make such post-compilation adjustments easier is a few simple steps:

  1. Add all the necessary new macros in the Class, pre-amble or your own package, as you discover them.
  2. Any items you might use extensively and maybe you bound to change your mind as to how you present them, create macros for them. As for example you might be writing a book on Maritime History and you may want all the names of the ships in italics, rather create a macro \ship. Same goes for items such as "Dr.~Name", where you may want to adjust so that they don't break along two lines.
  3. Images and floats give a lot of post-compilation issues, as well as lists and tables. use the right settings.
  4. Use the "spiral" technique while writing.

Having said the above there is room for a pre-processor to (All)TeX that can do a bit of automatic correction of common errors, format code blocks (if you writing anything that has to do with coding) and other similar small drudgery type of works. Small scripts in Perl, if you fancy cartoon swearing type syntax or Python if you are a perfectionista can go a long way in making life easier.

yannisl
  • 117,160
  • Actually, your answer contains an (in my opinion) good example: fiddling with the column lengths in a multi-column document. It is a very, very common situation for magazine-style publications with many short paragraphs in a 2- or 3-column layout that one wants to shift lines from one column to an adjacent one without wanting to affect page breaks. One solution might be to let the user make date-stamped "correction annotations" that will be ignored upon recompilation (i.e. the user would have to renew the date for them to be reactivated, or similar). – Lover of Structure Dec 30 '12 at 11:53
  • But really what's missing is a LaTeX coding infrastructure for this sort of thing. To see whether there is something akin to that is part of why I asked :-) – Lover of Structure Dec 30 '12 at 11:58
  • @LoverofStructure Please see my comment on intractability under the original question. – yannisl Dec 30 '12 at 12:03