I have the following sequence definition:
I can't find a way to write this in Latex. Any hints where to start?
math-mode
I have the following sequence definition:
I can't find a way to write this in Latex. Any hints where to start?
As with learning any spoken language, getting the hang of expressing your math thoughts in TeX and LaTeX takes some time, and it requires quite a bit of practice to become truly proficient. And, as with learning any spoken language, the learning curve does flatten out considerably after a while, and writing math in LaTeX will seem to have become second nature. (Aside: I've been using TeX and LaTeX for more than 20 years.)
That said, I've found that the following "tricks" do help ease the learning process, and they tend to save you a lot of keystrokes in the process:
Do study the manuals of the amsmath
package; they're chock-full of good examples of interesting (to look at!) formulas. Really! The user guide of amsmath
package shows how to use many great commands for typesetting equations and for entering matrices, to list just two examples of math-writing.
Use a text editor that provides various syntax highlighting methods and highlights matching parentheses, brackets, and curly braces. If the editor gives you pull-down menus to choose and click math terms, all the better; however, you'll likely find yourself using this particular piece of support less and less.
After you've entered a few formulas, take a look at the code and decide if there are any repeated stretches of code, such as second partials, integrals, and numerators and/or denominators of fractions. If these elements occur reasonably frequently, it's worth defining them as macros in your document's preamble and invoking them as needed in the main text. For example, if you have a lot of second partial derivatives, you may want to define a macro like
\newcommand{\secondp}[3]{\ensuremath{\displaystyle%
\frac{\partial^{2}\!{#1}}{\partial{#2}\,\partial{#3}}}}
You'd invoke this macro as follows: \secondp{f(x,y)}{x}{y}
or, if each argument consists of a single character, as \secondp f x y
. (Putting braces around the f
, x
, and y
won't hurt, of course, and it would likely make the code more readable as well.)
What if you have a lot of own second partial expressions? Piece of cake -- just define another macro that takes two inputs:
\newcommand{\ownsp}[2]{\ensuremath{\displaystyle%
\frac{\partial^{2}\!{#1}}{\partial{#2}^2}}}
Two side benefits of using macros in this way are:
they will save you a lot of typing over time and
they will eliminate a major source of typos (and hence frustration arising from having to track down typos!).
In the process of using macros frequently, you'll find that it becomes entirely natural to scrutinize formulas dispassionately, like an architectural critic who looks at the edifice as a whole, rather than like a laborer whose sole concern is how to place the next brick, or gargoyle, or whatever! By looking at the "big picture," so to say, you'll develop a facility to spot flaws in your edifice that you wouldn't be able to discover otherwise. E.g., is some part of the integrand "missing"? Should that be a minus sign instead of a plus sign?
In addition, make a habit of scrutinizing your code for ways to separate, as much as possible, the content of your mathematical expressions from its appearance. What do I mean by this? A main feature of the entire structural philosophy of LaTeX is to separate content from appearance; while appearance depends (obviously!) on the content, it is also affected by decisions about how the content is formatted. While you may be comfortable with your formatting decisions, your thesis adviser, a journal editor, or co-authors may desire different styles for formatting various terms. If you've hard-coded (using lower-level LaTeX/TeX commands) all of the formatting commands, you're going to have to spend a lot of time re-formatting the content of your work to meet these new requirements.
Take, for instance, the case of the cardinality of some set A
. This is sometimes (often?) displayed as |A|
. Now, some people like this formatting choice, but others prefer ||A||
(double vertical bars), or whatever. If you've defined a macro \card
as follows: \newcommand{\card}[1]{\ensuremath\left|#1\right|}
(implementing the former style) and have been using it consistently, your extra work should somebody demand a different style will be minimal. A side benefit of using the macro \card
is that it emphasizes the logic of your code rather than the appearance -- never a bad thing, right?
To give a different example: if you have lots of determinants of matrices, you're probably aware that they are required to be displayed as |A|
in some journals but as [A]
or det(A)
in others, and in yet different styles in further journals. In order not to have to reformat all of your input to meet the formatting requirements of a particular journal, it's best to use a macro named \det
each time your enter the determinant of a matrix. Actually, the macro \det
is already defined, as a "math operator" that sets the letters "det" in upright (not italicized} text mode. If you find that you'd really prefer to have determinants typeset as det(A)
-- with the matrix being the argument of the \det
command -- or as |A|
instead of the default det A
, you could redefine the \det
macro, say as follows:
\let\origdet\det
%% You should comment out one of the two next renewcommands
\renewcommand{\det}[1]{\origdet\mathopen{}\left(#1\right)} % to get "det(A)"
\renewcommand{\det}[1]{\left\lvert#1\right\rvert} % to get "|A|"
Finally, I strongly recommend that you collect all of your macros in a so-called LaTeX style file (named, say, mymacros.sty
), and store this file somewhere in the LOCALTEXMF tree. That way, you can load the style file from your documents with the command \usepackage{mymacros}
, and you'll always have easy access to your macros. And, if you ever want to redefine some of the macros, you'll only have to do so once.
Another change you might want to make to your macros is (if you haven't already done so from the very beginning) is to add copious comments as to what they're supposed to achieve. (Of course, providing copious comments is considered a good programming habit everywhere, not just among LaTeX-ers.)
Happy TeXing!
First, never use $\Pi$
when you obviously mean $\prod$
. Second, I guess dots here between $R_i$
and $ID$
should be centered.
Here is what I got:
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\Dist}{Dist}
\begin{document}
\pagestyle{empty}
\begin{displaymath}
MR(e) = \prod_{(R_i\cdot ID, R_j\cdot ID)}
\underset{\Dist_{sp}(r_i,r_j)\le\delta}{(R_i\bowtie R_j)}
\end{displaymath}
\end{document}
Best Answer
Since the other
cases
questions ask some specific questions about it, here's a working example:The
mathmode
documentation is extremely helpful for answering these sorts of questions. You can find it on your system usingtexdoc
or its equivalent.