GeneralSeparating Meaning and Presentation

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
internic
Posts: 3
Joined: Thu May 27, 2010 3:30 am

Separating Meaning and Presentation

Post by internic »

I'm not certain whether to put this in the math or general section, but I've chosen the general section because the question is, I think, a general one even if the application in question at the moment is mathematical.

When I write mathematical documents, I find I would really like to separate the mathematical object represented from the symbols that represent it. I'm tempted to define my own commands for the various mathematical objects, so that I can change notation later easily if I choose by simply changing those command definitions. For example, the \vec command gives puts an arrow over the top of a variable, but I find myself wanting to define a \vector command which I can then later choose to be an arrow on top, or bold face, or underlined, etc. as I see fit. The idea is not unlike the separation between meaning and presentation in HTML+CSS. I think I have read that it is generally considered to be bad LaTeX form to define a lot of new commands. I don't know why this is, exactly, although one reason I can think of is that it might make your tex files hard for others to read or use excerpts from.

What I'm trying to figure out is what are the reasons, if any, that it's undesirable to use new commands to separate meaning from presentation in the way I'm suggesting? If this method is undesirable, is there a better way to do it?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Separating Meaning and Presentation

Post by frabjous »

I actually do exactly this all the time: define my own commands, with the intention that I might decide to change the style globally later on.

I can't think of very many good reasons not to do this. The only things that come to mind are things such as:
  • If submitting for publication, the editors might prefer a document with fewer custom commands.
  • Your TeX editor might better know how to insert the regular commands and/or apply syntax highlighting to them. (Though many have the ability to learn and adapt.)
  • There are blogs and bulletin boards, etc., that allow you to insert little snippets of LaTeX code, but they won't usually allow you to use your own commands, so it's convenient not to get used to them.
  • Custom commands are often not handled as well by programs that convert LaTeX mark-up to other formats.
Personally I don't think any of these are particularly big problems, and you might well know ahead of time whether any of them should be a concern to you. I say, go ahead and define all the commands you want if it helps separating meaning and presentation.
internic
Posts: 3
Joined: Thu May 27, 2010 3:30 am

Separating Meaning and Presentation

Post by internic »

frabjous wrote: I can't think of very many good reasons not to do this. The only things that come to mind are things such as:
  • ...
  • There are blogs and bulletin boards, etc., that allow you to insert little snippets of LaTeX code, but they won't usually allow you to use your own commands, so it's convenient not to get used to them.
  • Custom commands are often not handled as well by programs that convert LaTeX mark-up to other formats.
Yes, the last two problems are annoying, which is why I had asked whether there's some piece of software that will "expand" out user-defined commands. (no responses, so I guess the answer is no) But if those are the only problems, then it's probably still worth doing.
Post Reply