Community

Our Precalculus course starts on Dec. 4. Master trig, complex numbers, and vectors and matrices in 2 and 3 dimensions. Click here to enroll today!
Login Register Memberlist Search AoPS Blogs Contests Galleries Forum Index
The time now is Fri Dec 04, 2009 5:26 am
All times are UTC - 8
View posts since last visit
View unanswered posts
Metapost & eqnarray
Moderators: fedja, stevem
Post new topic   Reply to topic View previous topicView next topic
19 Posts • Page 1 of 1
Author Message
stevem
Navier-Stokes Equations
Navier-Stokes Equations

Offline
Joined: 25 Apr 2004
Posts: 2201
Location: Dorset, UK

To rate posts you must be logged in
#1
Metapost & eqnarray
Articles in the latest PracTeX journal

The latest issue of The PracTeX Journal has a couple of articles that may be of interest to AoPS users:

PostPosted: Sat Dec 02, 2006 4:02 am  Back to top 
  ProfilePMWWW
Ravi B
Navier-Stokes Equations
Navier-Stokes Equations

Offline
Joined: 23 Jun 2003
Posts: 2464
Location: New York City
IndiaUnited States

To rate posts you must be logged in
#2
Thanks for the links to the articles (and for all your wonderful advice on LaTeX). From now on, I will replace eqnarray with align whenever I write a paper.

Is it possible to use the align environment on this forum? My attempts to gave me an "Unparseable or potentially dangerous latex formula".

PostPosted: Sat Dec 02, 2006 5:23 am  Back to top 
  ProfilePMWWWBlog
stevem
Navier-Stokes Equations
Navier-Stokes Equations

Offline
Joined: 25 Apr 2004
Posts: 2201
Location: Dorset, UK

To rate posts you must be logged in
#3
There seems to be a bug with the align environment on this forum. I'll ask Valentin if he would look into it.

PostPosted: Sat Dec 02, 2006 5:47 am  Back to top 
  ProfilePMWWW
stevem
Navier-Stokes Equations
Navier-Stokes Equations

Offline
Joined: 25 Apr 2004
Posts: 2201
Location: Dorset, UK

To rate posts you must be logged in
#4
Align workaround

Until the align environment bug is fixed, a workaround is to add \par before \begin{align} or \begin{align*} to get:
\par\begin{align}f(x) &= \int\sin x\: \text{d}x\\ g(x) &= \int \frac{1}{x}\: \text{d}x \end{align}
or
\par\begin{align*}f(x) &= \int\sin x\: \text{d}x\\ g(x) &= \int \frac{1}{x}\: \text{d}x \end{align*}

PostPosted: Sat Dec 02, 2006 7:36 am  Back to top 
  ProfilePMWWW
Ravi B
Navier-Stokes Equations
Navier-Stokes Equations

Offline
Joined: 23 Jun 2003
Posts: 2464
Location: New York City
IndiaUnited States

To rate posts you must be logged in
#5
Thanks for the workaround.

PostPosted: Sat Dec 02, 2006 8:18 am  Back to top 
  ProfilePMWWWBlog
roadnottaken
Yang-Mills Theory
Yang-Mills Theory


Offline
Joined: 27 Nov 2006
Posts: 551
Location: I'm a figment of my own imagination.

To rate posts you must be logged in
#6
Why does the "Math in \LaTeX" tutorial still list eqnarray rather than align? Huh?
_________________
Two roads diverged in a wood, and I-
I took the one less traveled by,
And that has made all the difference.

PostPosted: Tue Feb 06, 2007 9:50 am  Back to top 
  ProfilePMWWW
beans
Hodge Conjecture
Hodge Conjecture


Offline
Joined: 19 Feb 2007
Posts: 99
Location: UK

To rate posts you must be logged in
#7
I don't really see what's wrong with eqnarray. I mean it does what you want it to do!

PostPosted: Sun Apr 15, 2007 8:22 am  Back to top 
  ProfilePMWWW
Ravi B
Navier-Stokes Equations
Navier-Stokes Equations

Offline
Joined: 23 Jun 2003
Posts: 2464
Location: New York City
IndiaUnited States

To rate posts you must be logged in
#8
Did you read the article that the first post links to? In eqnarray, the spacing is off, and the equation numbers are buggy.

PostPosted: Sun Apr 15, 2007 8:35 am  Back to top 
  ProfilePMWWWBlog
stevem
Navier-Stokes Equations
Navier-Stokes Equations

Offline
Joined: 25 Apr 2004
Posts: 2201
Location: Dorset, UK

To rate posts you must be logged in
#9
As Why not use eqnarray? says "The environment eqnarray is attractive for the occasional user of mathematics in LaTeX documents" but it then goes on to say "it makes a serious mess of spacing" as is shown in 2.1 of the Avoid eqnarray! article. That article shows that there are other problems too.

So why not use the grown-up method viz align which always works and which is "which is designed with the needs of mathematicians in mind (as opposed to the convenience of LaTeX programmers)"?

PostPosted: Sun Apr 15, 2007 8:41 am  Back to top 
  ProfilePMWWW
beans
Hodge Conjecture
Hodge Conjecture


Offline
Joined: 19 Feb 2007
Posts: 99
Location: UK

To rate posts you must be logged in
#10
I skimmed through it Embarassed But I don't need to number my equations. (This is my first time using eqnarray you see, so I suppose it's best that I stop right there!)

I have a question for align though. I'm confused with the {} symbols that were used. What do they do and are they really necessary?

EDIT: Can someone please tell me what's wrong with the following:

\begin{align*}
v\dfrac{dv}{dx}\underline{k} &= -g\underline{k} -\gamma v^2 \underline{k}

\end{align*}

It doesn't appear on the pdf file! Sad Thanks.

PostPosted: Sun Apr 15, 2007 8:58 am  Back to top 
  ProfilePMWWW
stevem
Navier-Stokes Equations
Navier-Stokes Equations

Offline
Joined: 25 Apr 2004
Posts: 2201
Location: Dorset, UK

To rate posts you must be logged in
#11
beans wrote:
I have a question for align though. I'm confused with the {} symbols that were used. What do they do and are they really necessary?
You can see the difference here:
With {}
\par\begin{align*}x ={}& x \\ &+x \\ ={}& x \end{align*}
without {}
\par\begin{align*}x = & x \\ &+x \\ = & x \end{align*}
beans wrote:

EDIT: Can someone please tell me what's wrong with the following:

\begin{align*}
v\dfrac{dv}{dx}\underline{k} &= -g\underline{k} -\gamma v^2 \underline{k}

\end{align*}

It doesn't appear on the pdf file! Sad Thanks.
Have you looked at the error messages? Click on the ->! on the toolbar on the top right (keep pressing for more irrelevant messages) and it will tell you about a paragraph ending before \align* is complete which is LaTeX-speak for 'remove the blank line just before \end{align}'
Last edited by stevem on Sun Apr 15, 2007 9:34 am; edited 1 time in total 
PostPosted: Sun Apr 15, 2007 9:17 am  Back to top 
  ProfilePMWWW
beans
Hodge Conjecture
Hodge Conjecture


Offline
Joined: 19 Feb 2007
Posts: 99
Location: UK

To rate posts you must be logged in
#12
Best go and stick some {} into my document then!

stevem wrote:
Have you looked at the error messages? Click on the ->! on the toolbar on the top right (keep pressing for more irrelevant messages) and it will tell you about a paragraph ending before \align* is complete which is LaTeX-speak for 'remove the blank line just before \end{align}'


Thanks a lot! You see I have loads of error messages, warnings and bad boxes, so I just ignore them Embarassed (they don't make much sense you see) but thanks a lot Mr. Green

PostPosted: Sun Apr 15, 2007 9:28 am  Back to top 
  ProfilePMWWW
stevem
Navier-Stokes Equations
Navier-Stokes Equations

Offline
Joined: 25 Apr 2004
Posts: 2201
Location: Dorset, UK

To rate posts you must be logged in
#13
beans wrote:
Best go and stick some {} into my document then!
You won't need to do that unless you have something like that second line. Normally you get
\par\begin{align*}x = x \\ = x \end{align*}
which doesn't need {} and is fine.

beans wrote:
Thanks a lot! You see I have loads of error messages, warnings and bad boxes, so I just ignore them Embarassed (they don't make much sense you see) but thanks a lot Mr. Green
Trying to get rid of those messages is the way to learn more about LaTeX, though I admit it takes time and I know you are short of that.

PostPosted: Sun Apr 15, 2007 9:38 am  Back to top 
  ProfilePMWWW
beans
Hodge Conjecture
Hodge Conjecture


Offline
Joined: 19 Feb 2007
Posts: 99
Location: UK

To rate posts you must be logged in
#14
stevem wrote:
You won't need to do that unless you have something like that second line. Normally you get
\par\begin{align*}x = x \\ = x \end{align*}
which doesn't need {} and is fine.
Oh I see now. I was also(!) wondering about the spacing between the lines. You see I've got quite a few integral signs about and the document doesn't look neat because it seems that the line above is sitting on the line below! Is there anything that can be done about this?

stevem wrote:
Trying to get rid of those messages is the way to learn more about LaTeX, though I admit it takes time and I know you are short of that.
You got the time bit right. I did try to work through the errors on my first coursework, that's why it's still not complete! (and the fact that I need matlab Mr. Green ). I just want this done for tomorrow, and maybe later will try to get rid of the error messages. Smile

PostPosted: Sun Apr 15, 2007 9:57 am  Back to top 
  ProfilePMWWW
stevem
Navier-Stokes Equations
Navier-Stokes Equations

Offline
Joined: 25 Apr 2004
Posts: 2201
Location: Dorset, UK

To rate posts you must be logged in
#15
beans wrote:
I was also(!) wondering about the spacing between the lines. You see I've got quite a few integral signs about and the document doesn't look neat because it seems that the line above is sitting on the line below! Is there anything that can be done about this?
That shouldn't happen. Could you post a minimal document showing that problem? By that I mean everything including the preamble (ie before \begin{document}) but just including a few lines where the integrals look wrong.

Oh and if you include it on the forum inside [code ] ... [/code ] it won't misinterpret the dollar signs.

PostPosted: Sun Apr 15, 2007 10:07 am  Back to top 
  ProfilePMWWW
beans
Hodge Conjecture
Hodge Conjecture


Offline
Joined: 19 Feb 2007
Posts: 99
Location: UK

To rate posts you must be logged in
#16
stevem wrote:
beans wrote:
I was also(!) wondering about the spacing between the lines. You see I've got quite a few integral signs about and the document doesn't look neat because it seems that the line above is sitting on the line below! Is there anything that can be done about this?
That shouldn't happen. Could you post a minimal document showing that problem? By that I mean everything including the preamble (ie before \begin{document}) but just including a few lines where the integrals look wrong.

Oh and if you include it on the forum inside [code ] ... [/code ] it won't misinterpret the dollar signs.
Well I might have slightly exageratted the thing- you see I like a lot of space it seems! Embarassed

It's readable, but anyway heres what you asked for:
Code:
 \documentclass[titlepage, a4paper]{article}
\oddsidemargin=0in
\usepackage{fancyhdr}
\usepackage{amssymb}
\usepackage{upquote}
\usepackage{amsmath}
\usepackage[top=3.5cm,bottom=2.7cm,text={6.5in,9in},centering]{geometry}
\usepackage[pdftex]{graphicx}
\pagestyle{fancy}
\rhead{}   % My name
\lhead{Coursework}
\cfoot{\thepage}
\parindent=0in
\title{{\Huge } \\ {\Huge Coursework}} 
\author{{\Large }} % Author
\date{}
\begin{document}

\begin{align*}
-\displaystyle\int \dfrac{v}{g+ \gamma v^2} \:dv \:\underline{k} \quad  = & \quad \displaystyle\int \; dx :\underline{k}\\
\frac{-1}{2\gamma }\ln(g+\gamma v^2) \underline{k} \quad = & \quad x\underline{k} + C
\end{align*}\\


It's erm.. messy! The -1 seems to hang about the integral, but is that just me being fussy? :-0

PostPosted: Sun Apr 15, 2007 10:18 am  Back to top 
  ProfilePMWWW
stevem
Navier-Stokes Equations
Navier-Stokes Equations

Offline
Joined: 25 Apr 2004
Posts: 2201
Location: Dorset, UK

To rate posts you must be logged in
#17
You can change the vertical spacing by replacing \\ between the 2 equations with \\*[2ex] which I agree looks better (2ex means twice the height of an x in the current font, of course you can change it to give as much space as you like).

By the way, you don't need \displaystyle here as the align environment does that for you automatically.

PostPosted: Sun Apr 15, 2007 10:31 am  Back to top 
  ProfilePMWWW
beans
Hodge Conjecture
Hodge Conjecture


Offline
Joined: 19 Feb 2007
Posts: 99
Location: UK

To rate posts you must be logged in
#18
stevem wrote:
You can change the vertical spacing by replacing \\ between the 2 equations with \\*[2ex] which I agree looks better (2ex means twice the height of an x in the current font, of course you can change it to give as much space as you like).

By the way, you don't need \displaystyle here as the align environment does that for you automatically.
Thanks once again Steve. Smile It worked a treat- looks pretty darn neat! And you saved me from a lot of typing as well. (I've been going through the errors, and it seems I have lots of extra { flying about, although I don't understand what bad boxes are!)

PostPosted: Sun Apr 15, 2007 2:12 pm  Back to top 
  ProfilePMWWW
stevem
Navier-Stokes Equations
Navier-Stokes Equations

Offline
Joined: 25 Apr 2004
Posts: 2201
Location: Dorset, UK

To rate posts you must be logged in
#19
beans wrote:
although I don't understand what bad boxes are!)
They are the least important things to worry about which is why TeXniCenter relegates them to below Errors and Warnings.

In the example you gave you had
\end{align*}\\
The \\ isn't needed on the end and gives "underfull \hbox (badness 1000)". That means that LaTeX couldn't justify the line left and right properly, which isn't surprising because there isn't anything there. Badness is an estimate of how much stretching LaTeX had to do to fill the line, so the lower the better. Remove the \\ and the warning goes.

Sometimes LaTeX can't break a line in the right place eg due to a long formula or poor hyphenation so it will give a overfull \hbox warning. This will be much more obvious as you'll see text go into the margin - though if it's only by a tiny amount you might ignore it rather than having to make things look awkward.

Thus these bad boxes* are to alert you to possible problems, but if the page looks right then you can ignore them.

*LaTeX puts text into boxes behind the scenes so it can get the spacing right. Justification, for example, means tweaking things slightly with a bit of spacing. The methods it uses are complicated which is why it produces much better results than anything a word processor can achieve.

PostPosted: Sun Apr 15, 2007 2:43 pm  Back to top 
  ProfilePMWWW
Display posts from previous:   Sort by:   
19 Posts • Page 1 of 1
Post new topic   Reply to topic View previous topicView next topic
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
You cannot post calendar events in this forum


© Copyright 2008 AoPS Incorporated. All Rights Reserved. • FoundationPrivacyContact Us