LaTeX implementation ready for testing on Physics Forums

  • Context: LaTeX 
  • Thread starter Thread starter Greg Bernhardt
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
161 replies · 8K views
A better version?

[tex] \newcommand{\lineUp}{<br /> \begin{picture}(10,10)(0,0)<br /> \put(0,0){\line(1,1){10}} \put(2,0){\line(1,1){10}}<br /> \end{picture}<br /> }<br /> \newcommand{\lineDn}{<br /> \begin{picture}(10,10)(0,0)<br /> \put(0,10){\line(1,-1){10}}<br /> \end{picture}<br /> }<br /> <br /> \begin{array}{cc}<br /> \lineUp & \lineDn \\<br /> \lineDn & \lineUp<br /> \end{array}[/tex]
 
Physics news on Phys.org
[tex] \newcommand{\lineUp}{<br /> \begin{picture}(10,10)(0,0)<br /> \put(0,0){\line(1,1){10}} \put(2,0){\line(1,1){10}}<br /> \end{picture}<br /> }<br /> <br /> \newcommand{\lineDn}{<br /> \begin{picture}(10,10)(0,0)<br /> \put(0,10){\line(1,-1){10}}<br /> \end{picture}<br /> }<br /> <br /> \begin{array}{ccccccc}<br /> \ &\ &\ &\mathrm{H}&\ &\ &\ \\<br /> \ &\ &\ &\mid&\ &\ &\ \\<br /> \ &\ &\ &\mathrm{C}&\ &\ &\ \\<br /> \ &\ &\ &\lineUp \lineDn &\ &\ &\ \\<br /> \ &\mathrm{H}&-&\mathrm{C}\ \mathrm{C}&-&\mathrm{H}\\<br /> \ &\ &\ &\mid\ \|&\ &\ \\<br /> \ &\mathrm{H}&-&\mathrm{C}\ \mathrm{C}&-&\mathrm{H}\\<br /> \ &\ &\ & \lineDn \lineUp &\ &\ &\ \\<br /> \ &\ &\ &\mathrm{C}&\ &\ &\ \\<br /> \ &\ &\ &\mid&\ &\ &\ \\<br /> \ &\ &\ &\mathrm{H}&\ &\ &\ \\<br /> \end{array}[/tex]

Oh well... not too bad. The good thing is that you can play with the "picture" command to make it nicer.
 
Last edited:
Originally posted by ahrkron
[tex] \newcommand{\lineUp}{<br /> \begin{picture}(10,10)(0,0)<br /> \put(0,0){\line(1,1){10}} \put(2,0){\line(1,1){10}}<br /> \end{picture}<br /> }<br /> <br /> \newcommand{\lineDn}{<br /> \begin{picture}(10,10)(0,0)<br /> \put(0,10){\line(1,-1){10}}<br /> \end{picture}<br /> }<br /> <br /> \begin{array}{ccccccc}<br /> \ &\ &\ &\mathrm{H}&\ &\ &\ \\<br /> \ &\ &\ &\mid&\ &\ &\ \\<br /> \ &\ &\ &\mathrm{C}&\ &\ &\ \\<br /> \ &\ &\ &\lineUp \lineDn &\ &\ &\ \\<br /> \ &\mathrm{H}&-&\mathrm{C}\ \mathrm{C}&-&\mathrm{H}\\<br /> \ &\ &\ &\mid\ \|&\ &\ \\<br /> \ &\mathrm{H}&-&\mathrm{C}\ \mathrm{C}&-&\mathrm{H}\\<br /> \ &\ &\ & \lineDn \lineUp &\ &\ &\ \\<br /> \ &\ &\ &\mathrm{C}&\ &\ &\ \\<br /> \ &\ &\ &\mid&\ &\ &\ \\<br /> \ &\ &\ &\mathrm{H}&\ &\ &\ \\<br /> \end{array}[/tex]

Oh well... not too bad. The good thing is that you can play with the "picture" command to make it nicer.

Yeah, I just started playing around with it last night.
 
[tex] <br /> \newcommand{\lineUp}{\put(-10,-4){\line(1,1){20}}}<br /> \newcommand{\lineDn}{\put(-9,13){\line(1,-1){20}}}<br /> <br /> \newcommand{\dlineup}{\put(-10,0){\line(1,1){15}}\put(-6,-6){\line(1,1){15}}}<br /> <br /> \newcommand{\dlinedn}{\put(-9,9){\line(1,-1){15}}\put(-5,15){\line(1,-1){15}}}<br /> <br /> \begin {array}{ccccccccc}<br /> \ &&&\ \ &\mathrm{H}&\ \ &&&\\<br /> <br /> \ &&&&\mid&&&&\\<br /> \ &&&\ \ &\mathrm{C}&\ \ &&&\\<br /> <br /> \ &&&\dlineup&&\lineDn&&&\\<br /> <br /> \mathrm{H}&-&\mathrm{C}&&&&\mathrm{C}&-&\mathrm{H}\\<br /> <br /> \ &&\mid&&&&\mid\mid&&\\<br /> <br /> \mathrm{H}&-&\mathrm{C}&&&&\mathrm{C}&-&\mathrm{H}\\<br /> <br /> \ &&&\dlinedn&&\lineUp&&&\\<br /> <br /> \ &&&\ \ &\mathrm{C}&\ \ &&&\\<br /> <br /> \ &&&&\mid&&&&\\<br /> <br /> \ &&&\ \ &\mathrm{H}&\ \ &&&<br /> <br /> <br /> \end{array}[/tex]

Okay, this is more like it!
 
Before you guys spend all your time reinventing the wheel, why don't you see if there's a LaTeX package to display chemical structures this way?

- Warren
 
Maybe this one?

http://www.educat.hu-berlin.de/~voss/LaTeX/misc/chemistry.phtml

- Warren
 
Last edited by a moderator:
Originally posted by chroot
Before you guys spend all your time reinventing the wheel, why don't you see if there's a LaTeX package to display chemical structures this way?

- Warren

But it's more FUN this way!
 
This is a very long statement with some chemical formulas like [tex] \inline{H_2 O}[/tex] stuck into gauge how the alignment tags are affecting the image placement. And I might as well include some methane here too, just for fun: [tex]\inline{C H_4}[/tex]. I might even consider [tex]\inline{y = mx + b}[/tex] or [tex]\inline{\frac{1}{\sqrt{1 - v^2/c^2}}}[/tex] or even [tex]\inline{G_\textrm{diffeo}}[/tex]. Don't worry about this text, since it's not relevant!

And just to make sure the display mode formulas still work:

[tex] e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = \lim_{n\rightarrow\infty} (1+x/n)^n[/tex]

versus including inline, like this [tex]\inline{e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = \lim_{n\rightarrow\infty} (1+x/n)^n<br /> }[/tex].

- Warren
 
Last edited:
Let's see how this looks, embedding a little inline math inside a very long sentence: [tex]\inline{\sum_i x^i}[/tex]. I think it should look okay! Let's find out. Some formulas for common chemicals are [tex]\inline{CH_4}[/tex] and [tex]\inline{H_2 O}[/tex]. They're more likely to put things like [tex]\inline{x^2}[/tex] and so on, and I think that should look great! How about [tex]\inline{x}[/tex] and [tex]\inline{x^2}[/tex] and [tex]\inline{x_i}[/tex]...

There, how's that Monique?

- Warren
 
I think it looks very nicely inline! There is still a problem though with text subscripts, which seem to be lower than number subscripts, see the following example. I think the font might be done a tiny bit smaller too.

In grade school, we were taught that when a hydrogen atom shares its electron with a chlorine atom, a covalent bond is formed. It holds together the new molecule, hydrogen chloride. Since this compound exists as a gas at standard conditions, it is designated by the chemical formula [tex]\inline{HCl_{(g)} }[/tex]. We also learned that when hydrogen chloride gas is dissolved in water, it becomes aqueous hydrogen chloride [tex]\inline{HCl_{(aq)} }[/tex]. The proper name for this is hydrochloric acid.

Later on, we were informed that the molecule does not remain whole once in an aqueous solution. It ionizes to form [tex]\inline{H^+_{(aq)}}[/tex] ions and [tex]\inline{Cl^-_{(aq)}}[/tex] ions. We were left with this notion, relatively unaltered, until the Bronsted-Lowry unit, where we learned that the [tex]\inline{H^+_{(aq)}}[/tex] ion actually reacts with a water molecule to form the hydronium ion: [tex]\inline{H_3O^+_{(aq)}}[/tex]. Another way of looking at it is that the water molecule accepts a proton “donation” from [tex]\inline{\HCl_{(aq)} }[/tex]. A crucial point in this unit was that a strong acid is defined as one that nearly completely dissociates (or is it ionizes?) in this manner.

Whoa! That’s the kicker. This means that the final products in the process of dissolving hydrogen chloride are almost entirely hydronium ions and chloride ions. This is the final “acidic” solution. It is the one that displays all of the empirical properties of an acid (i.e. conducts electricity, turns blue litmus red, has a pH < 7.0, etc.). These empirical properties can be attributed entirely to the hydronium ion. Put another way, in the final acidic solution, the so-called strong acid, [tex]\inline{HCl_{(aq)} }[/tex], is present in negligible quantities. So what is an acid, and how can we call [tex]\inline{HCl_{(aq)} }[/tex] an acid? Again, I emphasize that for all “strong acids”, the aqueous acidic solution is composed almost entirely of hydronium ions (and the corresponding anions). If this is true, then does the term “hydrochloric acid” really have any meaning at all?
 
I'm sorry Monique, I'm not sure what you're talking about. Are you suggesting that [tex]\inline{HCl_{(g)} }[/tex] and [tex]\inline{CH_{(4)}}[/tex] look different? They don't. Perhaps you're suggesting that [tex]\inline{HCl_{(g)} }[/tex] and [tex]\inline{CH_{4}}[/tex] look different? They ought to. One has parentheses in the subscript, which are "tall" symbols, while the other does not. Remember that TeX has to lay things out to leave room for superscripts! Putting parentheses around a subscript will necessary push it downwards.

Oh, and as far as the size... HCl and [tex]\inline{HCl}[/tex] look pretty close to me.

- Warren
 
This is just a test: [tex]\sin(\theta)[/tex]. Does this work? I imagine it will work nicely: [itex]\sin(\theta)[/itex]

- Warren