PDA

View Full Version : offtopic: latex question



phen
May 30th, 2006, 09:58 AM
hello all,
maybe one of you is able to help me with this offtopic-problem:
I work with latex for my studies, and i have to write the same equations very very often. I wonder if it is possible to save often used expressions in some kind of a variable?

for example, i have to write \frac{c1}{M d 3} in nearly every equation. i could save it in a variable like %fraction_1% or something...

thank you for your help!

GeneralZod
June 1st, 2006, 09:46 PM
Look into the \newcommand ... command :) Something along the lines of:



\newcommand{\phenfrac}{\ensuremath{\frac{c1}{M d 3} i}}


You can now replace this string of symbols with "\phenfrac". The \newcommand call should be made near the beginning of your document - many people have a separate "definitions.tex" file containing all their custom macros/ commands/ environments, which they then \include into the main document.

It is highly recommended that you make use of this as much as is possible, and not just to save your typing fingers - if you ever need to change the notation for something, you'll only need to change it in one place. Plus, separating semantics (the meaning of the string of symbols "\frac{c1}{M d 3} i" which I assume stands for something special [I've called this "something" "phenfrac"; you'll doubtless have a more descriptive name for it!]) from the actual presentation (the string of symbols representing the concept of phenphrac; i.e. the string "\frac{c1}{M d 3} i") is generally good practice in all fields. You can use arguments/ parameters with \newcommand, too, in case "frac{c1}{M d 3} i" is a template that you wish to put specific values into at different times.

curuxz
June 1st, 2006, 11:23 PM
call me stupid...but from the title i expected this thread to be about something else entirely...

Rikostan
June 2nd, 2006, 12:06 AM
call me stupid...but from the title i expected this thread to be about something else entirely...

Ahahaha I was hoping it was about something else. :)

sherlock-holmes
June 2nd, 2006, 12:40 AM
Ahahaha I was hoping it was about something else. :)


yup... the 'x' at the end....:cool:

phen
June 7th, 2006, 09:30 PM
hehe, what did you expect? :)

thank you, generalzod! that's exactly what i was looking for!