It's not entirely clear what you want, exactly. But you can easily define a macro which spells out the name and can therefore be changed once in the document. For example, if you have something that for the moment you are calling 'class', you could define the following macro:
\newcommand*{\class}{class}
(The *
here means that the macro can't contain any paragraph breaks; see the following question for more details on this.
What's the difference between \newcommand and \newcommand*?
In your text, you would then type \class
in every place you want that object name. If you decide that you want to call a class a method, you would simply redefine the \class
macro:
\newcommand*{\class}{method}
There are a couple of things you need to bear in mind with this sort of solution. First, spaces after macros are ignored, so if you your source has
In this \class we strip out spaces.
It will be rendered as In this classwe strip out spaces, which is not what you want. You can't simply add a space to the definition, since this will incorrectly add spaces before e.g. punctuation marks, where you don't want them. So there are two ways around this. One is to simply insert an overt space whenever you need one using \
:
In this \class\ we strip out spaces.
The other solution is to use the xspace
package, which inserts a space automatically and takes care not to insert the space before punctuation.
\usepackage{xspace}
\newcommand*{\class}{class\xspace}
Then you don't need to type the explicit space yourself. Note, however, that there are some drawbacks to using the xspace
approach. See:
Drawbacks of xspace
The second pitfall with defining replacement macros this way, is that they don't adjust for things like plurals and capitalization. To capture these cases, it's probably easiest to simply define uppercase and plural version of the macros themselves. (You could do other fancier things, but at the expense of making your source less readable.) So you could define:
\newcommand*{\Class}{Class}
\newcommand*{\classes}{\class es}
\newcommand*{\Classes}{\Class es}
The following article by Will Robertson is a useful guide to these sorts of techniques:
Productivity with Macros and Packages
Here is a small document with all of the examples above included in it.
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{xspace}
\newcommand*{\class}{class} % if your command will have multiple lines omit the *
\newcommand*{\Class}{Class} % uppercase version
\newcommand*{\classes}{\class es} % plural versions
\newcommand*{\Classes}{\Class es}
\begin{document}
If we don't add an explicit space after the \class macro it doesn't work as we expect.
We can make the \class\ macro work by adding the space explicitly.
Or if we change the macro to use the xspace package, it will insert the space automatically:
\renewcommand*{\class}{class\xspace}
Now the \class macro inserts a space, but not when there is punctuation following \class.
\end{document}
The only thing I haven't mentioned here is how to do all of this in LyX. The \newcommand
definitions go into your document preamble the way you would add any other raw LaTeX code to a document. If you will be using them a lot it might be useful to create a LyX layout to do this. For more on how to add customized environments to LyX see:
Create new paragraph style in LyX
The typography as displayed by LaTeX
is the correct one. A comma needs to be placed at the baseline.
If you need to make any adjustments rather place the fraction within brackets. Agreed that the comma can be mistaken as a prime, but remember that mathematics is read in context, i.e., if no primes are used on the variables it is highly unlikely that a mathematically inclined reader will mix it up.
I have checked the above with a couple of books and always the comma is as shown by LaTeX.
\documentclass{article}
\usepackage{amsmath}
\usepackage{mathpazo} % To get Palatino
\linespread{1.05} % See question 31064
\usepackage[small, euler-digits]{eulervm} % and now Euler
\begin{document}
If the number of independent variable is~$n$, we must have
\[
p = - \frac{n-2}{2}, \quad \text{or} \quad -\left(\frac{n-2}{2} + 1\right), \quad -\left(\frac{n-2}{2} + 2\right),\quad \left(\frac{n-2}{2+a}\right), \quad \dots.
\]
\end{document}
Your suggestion of raising the comma can lead to other problems such as $(a,b)\frac{a}{b},
resulting in the commas not lining up.
Best Answer
Yes.
I recently did a fairly similar thing in this paper. My coauthor and I were convinced that whatever notation we chose, we would get a comment from the referee along the lines of "The notation for X is awful. I suggest using Y." So I designed the paper to make it as easy as possible to change all the notation. At one point I even had it set up so that a single change would flip all actions from left to right (so that, for example,
f
followed byg
would beg f
instead off g
). So I have every sympathy for your situation and think that the general scheme is the right way to go.Yes.
Make your macros more obvious what they are. (This may already be true for you, in which case ignore this comment!). It's been said that you should write so that when you look again at the code in 6 months' time, you don't have to puzzle out what everything means. In my example above, I had macros of the form
\dcat
,\dobj
,\delt
for "The category D", "An object of D", and "An element of an object of D". It's not hard to remember what they mean, whilst still retaining the flexibility of changing how they are typeset. So my first piece of advice:The next is about saving time and energy. In my case, I found myself defining reams of these things, and all the same: I'd have a category and want to define objects, morphisms, elements, and variants thereof. All on the same basic pattern. So I wrote a "generator" macro that would take in a couple of basic parameters and then generate all the macros that I wanted to use (a crude sort of object-oriented programming). Of course, exactly how feasible that is for you depends on your abilities with TeX, but even if you feel it is beyond you right now, it is worth planning ahead a little and anticipating that you might put in place such a scheme and so choosing your names appropriately now. So my second piece of advice: