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.

  • 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
  • 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
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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