7

I am new to LaTeX and have completed my first document recently, and it came out to be excellent. However, I am not going to make several more documents which shall be similar. I found that although the style file provides a big relief, there are still a lot of design elements embedded in the document itself. My question:

  1. Is there a way to separate design from content?

  2. Do I need special tools to achieve that?

I come from HTML5/CSS background which might explain my expectation. Or maybe the expectation itself is incorrect.

More information: My documents are small articles ( weekly results from an experiment) running 2-3 pages. They contain mostly text and some graphs and figures which are automatically generated by a script. I wanted to automate this document generation using scripts. The strategy was that the content is generated from the experiment and the design template remains unchanged.

FlowRaja
  • 173
  • 3
    There are various ways to do this, and a lot will depend on your use case. Generally if you find yourself creating a lot of similar documents it makes sense to create a class (or possibly a package) for it. There are some similar questions on the site: How to make a standard preamble into a package and Is there a source function/capability in LaTeX. Also Style/class tutorials and Where do I start LaTeX programming?. – Alan Munn Dec 11 '13 at 18:28
  • 6
    You need to give us at least some slight clues. the answers to 1 and 2 are yes and no but it all depends on the details. One man's metadata is another man's data. You need to post a small example document showing the kind of constructs that you are concerned about, otherwise the question is likely to be closed as unclear or too broad. – David Carlisle Dec 11 '13 at 18:30
  • Unfortunately, some tweaking has to be made dependent on the current pagination --- one way to work around this is to have two package files, the second redefines all the commands which you need to accomplish your nice formatting, the first defines them all to do nothing --- for bonus points, assign all your macros to have names which can be easily searched for and deleted. – WillAdams Dec 11 '13 at 18:43
  • @WillAdams Why do you say that? It should not be necessary in most cases. Part of the point of TeX is precisely that TeX worries about that stuff so you don't have to. If you are manually tweaking on a per-document basis, something is wrong unless your documents are all special cases. – cfr Dec 11 '13 at 23:35
  • I actually do something like that. I use C programs to generate content which is stored in a file which I then \indlude in the main file. I try to keep as much LaTeX specific code out of the C code as possible, which I do by creating macros to do all the formatting. – John Kormylo Dec 12 '13 at 02:25
  • Unfortunately, (La)TeX's pagination algorithms aren't smart enough to adjust a paragraph to be longer or shorter by a line so as to balance a page spread, they won't run a given spread longer or shorter by a line so that a figure will fit on the same spread as its reference, it won't examine an entire chapter to see that the last page has only 5 lines, so should be paged a bit tight so as to lose those lines and empty that page, it won't look at an entire book to see that it would be better that a certain chapter start on a right, so the preceding chapter should be paged so as to somehow gain. – WillAdams Dec 12 '13 at 13:13
  • 1
    I think any .cls file tries to solve all design problems but people like to tweak class author's decisions. If you are looking for some example with not-so-a-la-LaTeX environments, take a look at labbook and its documentation. This class declares new environments like labday, experiment and subexperiment which replace LaTeX regular chapter and sections. All style/design decisions are provided in labbook.cls and you just have to write your text for every experiment. As usual, if you don't like their format, just change definitions in labbook.cls. – Ignasi Dec 12 '13 at 16:02
  • I think it is a cool idea. How does it differ from a package? – FlowRaja Dec 12 '13 at 16:09

1 Answers1

3

Write a package file which handles all the specific formatting you need by changing the LaTeX defaults/macros, load that. Never use anything but a standard (La)TeX macro/command.

Your document should still compile if you comment out your customizing package.

WillAdams
  • 7,187