geekhack

geekhack Community => Off Topic => Topic started by: timw4mail on Tue, 28 July 2009, 13:29:28

Title: LaTeX discussion
Post by: timw4mail on Tue, 28 July 2009, 13:29:28
This is mainly to split this off from the images thread...

I was looking into LaTeX for taking notes in my classes, since its difficult to incorporate Lewis dot structures into text in a regular Word Processor.

I've also wondered if there's an easy way to draw graphs in LaTeX.
Title: LaTeX discussion
Post by: talis on Tue, 28 July 2009, 13:51:16
Quote
Now if I could only figure out how to do Chemistry and Graphs with LaTeX...

Its usually easier to graphs in an external package, and just add them to the document as images.  Matlab works quite well for this as you can export directly to .eps.

Chemistry typesetting should be fairly easy.  I can't see it being much more then a mixture of super and sub-scrips around a few basic symbols.:

Code: [Select]
\begin{equation}
Fe_2O_3 + 2 Al \rightarrow 2 Fe + Al_2O_3
\end{equation}

(http://geekhack.org/attachment.php?attachmentid=3390&stc=1&d=1248805325)

For structural stuff take a look at chemtex and xymtex.

(note, I'm not a chemist, so I have no idea what this means)
Code: [Select]
\usepackage{xymtex}
.
.
.
\pyridinev{4==Cl}

produces an output like :

(http://geekhack.org/attachment.php?attachmentid=3391&stc=1&d=1248806157)


There is a lewis package specifically for that, tho it doesn't seem to be overly elegant.

Code: [Select]
\usepackage{lewis}
.
.
.
\lewis{F}{.}{.}{.}{.}{}{}{.}{.}--\lewis{F}{}{}{.}{.}{.}{.}{.}{.}

produces :

(http://geekhack.org/attachment.php?attachmentid=3392&stc=1&d=1248807062)
Title: LaTeX discussion
Post by: timw4mail on Tue, 28 July 2009, 14:03:28
Quote from: talis;105088
Its usually easier to graphs in an external package, and just add them to the document as images.  Matlab works quite well for this as you can export directly to .eps.
How do you actually add images?
I don't have, or know how to use Matlab, do you know if Maple can do anything similar?

Quote
Chemistry typesetting should be fairly easy.  I can't see it being much more then a mixture of super and sub-scrips around a few basic symbols.:

Code: [Select]
\begin{equation}
Fe_2O_3 + 2 Al \rightarrow 2 Fe + Al_2O_3
\end{equation}
Show Image
(http://geekhack.org/attachment.php?attachmentid=3390&stc=1&d=1248805325)


For structural stuff take a look at chemtex and xymtex.

(note, I'm not a chemist, so I have no idea what this means)
Code: [Select]
\usepackage{xymtex}
.
.
.
\pyridinev{4==Cl}
produces an output like :

Show Image
(http://geekhack.org/attachment.php?attachmentid=3391&stc=1&d=1248806157)



There is a lewis package specifically for that, tho it doesn't seem to be overly elegant.

Code: [Select]
\usepackage{lewis}
.
.
.
\lewis{F}{.}{.}{.}{.}{}{}{.}{.}--\lewis{F}{}{}{.}{.}{.}{.}{.}{.}
produces :

Show Image
(http://geekhack.org/attachment.php?attachmentid=3392&stc=1&d=1248807062)

That package is perfect...I just don't want to have to leave things out of my class notes because I can't type them in.
Title: LaTeX discussion
Post by: talis on Tue, 28 July 2009, 14:12:57
Anything that can export will work, .eps isn't necicary, you can use .jpg or pretty much any image format for that matter (eps are just vectorized images, so they scale nicely).  You just need to include the images.  Maple may be able to, there's probably a right click context menu export of a figure (its been a while since I used Maple).

I know there's a few ways to graph directly in LaTeX, but they've always seemed overly complicated, and are one of those things you have to look up every time you need them.

Graphics are easy to include, in its  simplest form :

Code: [Select]
\usepackage{graphicx}
.
.
.
\begin{figure}
\includegraphics[]{img/dc-dc-l-graph}
\end{figure}

Tho you can also scale, rotate, center, and annotate:

Code: [Select]
\begin{figure}
    \begin{center}
        \includegraphics[scale=.4]{img/dc-dc-l-graph}
    \end{center}
    \caption[Inductor selection guide]{DC-DC converter inductor selection guide.}
    \label{dc-dc-inductor-selection-graph}
\end{figure}

You can also scale relative to the width of the text field in the layout you are using:

Code: [Select]
\includegraphics[width=.8\textwidth, height=.45\textwidth]{res/car_res/pascar4_simple}\\
Title: LaTeX discussion
Post by: huha on Tue, 28 July 2009, 14:15:05
For chemistry stuff, there's always mhchem, which does it right--non-italic element names and slightly different sub- and superscript positions.

-huha
Title: LaTeX discussion
Post by: keyb_gr on Tue, 28 July 2009, 14:29:07
For drawing I'll be using Inkscape for now. Gnuplot graphs can be included easily, as the latter has an "epslatex" output terminal these days.
Title: LaTeX discussion
Post by: timw4mail on Tue, 28 July 2009, 14:49:31
Quote from: keyb_gr;105097
For drawing I'll be using Inkscape for now. Gnuplot graphs can be included easily, as the latter has an "epslatex" output terminal these days.

Inkscape does graphing?
Title: LaTeX discussion
Post by: talis on Tue, 28 July 2009, 15:38:06
You can try Gnuplot (there's cross platform releases), or take a look at Octave, which is an open source Matlab clone (without all the toolkit/simulink components).
Title: LaTeX discussion
Post by: DrunkenDonut on Tue, 28 July 2009, 19:43:50
Looks like you're covered with the formulas and chemistry stuff ...

I'll just add, if you're going to be producing PDFs out of all of this, pdflatex or pdftex (and probably some other package I can't recall) can import PNGs directly. PNG are also vector based so they scale nicely as well. You can also add pages from other PDF files easily too.
Title: LaTeX discussion
Post by: huha on Tue, 28 July 2009, 20:19:32
Quote from: DrunkenDonut;105176
PNG are also vector based so they scale nicely as well. You can also add pages from other PDF files easily too.


PNG aren't vector graphics I'm afraid. Still, nothing's hindering you from exporting your vector graphics as PDF--almost any graphics program has that option.

-huha
Title: LaTeX discussion
Post by: timw4mail on Tue, 28 July 2009, 20:51:36
Quote from: huha;105179
PNG aren't vector graphics I'm afraid. Still, nothing's hindering you from exporting your vector graphics as PDF--almost any graphics program has that option.

-huha

Although, it seems easier to just incorporate it as an EPS...

It's a shame that PDF is the defacto standard for vector text...its such a bloated, poorly-aged format.
Title: LaTeX discussion
Post by: timw4mail on Wed, 29 July 2009, 13:56:19
Oh, does anyone know of a LaTeX package for logic gates?
Title: LaTeX discussion
Post by: keyb_gr on Wed, 29 July 2009, 14:10:17
Quote from: timw4mail;105284
Oh, does anyone know of a LaTeX package for logic gates?

"pgf" seems to be useable. These m4 macros (http://www.ctan.org/tex-archive/graphics/circuit_macros/) may also be useful.

I might prefer an external drawing app here.
Title: LaTeX discussion
Post by: talis on Wed, 29 July 2009, 15:02:30
Quote from: keyb_gr;105294
"pgf" seems to be useable. These m4 macros (http://www.ctan.org/tex-archive/graphics/circuit_macros/) may also be useful.

I might prefer an external drawing app here.

Eagle cad may work as an external editor.  


Quote
Oh, does anyone know of a LaTeX package for logic gates?
If you're just trying to get the ideas across it may be better to stick with Boolean notation, much quicker to type out and captures all the same information:

Code: [Select]
\begin{equation}
\lnot ( A \land B )\lor C
\end{equation}
Title: LaTeX discussion
Post by: DrunkenDonut on Wed, 29 July 2009, 15:35:14
Quote from: huha;105179
PNG aren't vector graphics I'm afraid. Still, nothing's hindering you from exporting your vector graphics as PDF


Oooops, my bad. You're right, but I got it stuck in my head that it's vector somehow. I remember doing the PDF export for various images either through built-in exporting or print-to-PDF functionality.

Quote from: timw4mail;105181
Although, it seems easier to just incorporate it as an EPS...


I've had trouble with EPS in the past, especially with programs that don't output EPS quite the way you want. You'd have to go into each image and manually change the window boundaries and such. That's why PDF + PDF/PNG images was such a great combo. Less issues with the file formats and still got your work done, especially if many platforms came into play - Solaris, Windows, etc... Sometimes it's easier with EPS/PS, sometimes it's easier with PNG/PDF.