Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to typeset a problem solution highlighting dimensional analysis in LaTeX. What is the best way to format the following in LaTeX?

  1.345 g | 0.5 L | 1000 cm^3
 ---------|-------|----------- =  0.6725 g
   cm^3   |       |   1 L

I could use a table I guess but that seems wrong. A set of \frac commands would also work but not give exactly the same visual affect. (It would be really nice to cancel the units in the expression as well). Aside from digging into pstricks is there a better way to do this?

share|improve this question

migrated from stackoverflow.com Dec 28 '11 at 17:24

This question came from our site for professional and enthusiast programmers.

    
Quite apart from the appearance, I'm not sure I follow your dimensional analysis here! –  Joseph Wright Dec 28 '11 at 17:35
    
add comment

1 Answer 1

You could definitely use \frac to write the LHS components, and the cancel package provides a diagonal strike-through of elements. Here's a minimal example:

enter image description here

\documentclass{article}
\usepackage{cancel}% http://ctan.org/pkg/cancel
\begin{document}
\[
  \frac{1.345\,\textrm{g}}{1\,\cancel{\textrm{cm}^3}}\,
    \frac{0.5\,\cancel{\textrm{L}}}{1}\,
    \frac{1000\,\cancel{\textrm{cm}^3}}{1\,\cancel{\textrm{L}}}=0.6725\,\textrm{g}
\]
​\end{document}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

If the SW-NE diagonal crossing through L is visually unappealing, cancel also provides \bcancel, as well as xcancel (a combination of \cancel and \bcancel). The siunitx package can also be used to write numerals with units in a standard way.

share|improve this answer
2  
Seems like you hit 80 mathmode answers. ;-) –  lockstep Dec 28 '11 at 17:28
    
Keeping track, are we? :) –  Werner Dec 28 '11 at 17:29
    
Is \ell a legal symbol for "liter"? It's used, but not endorsed by the BIPM. The correct spacing for units is \,, not \;, but perhaps here it can stand. –  egreg Dec 28 '11 at 17:30
    
See also tex.stackexchange.com/questions/15916/… and tex.stackexchange.com/questions/20643/… for an alternative to cancel. –  N.N. Dec 28 '11 at 17:32
    
@egreg: I'll update my answer to reflect the notation choice. Thanks for the note on spacing; looking back at it, I should actually remove the \, from 1000 as well, since it is perhaps more common to not have that for 4-digit numerals, leading to the initial choice of \;. –  Werner Dec 28 '11 at 17:35
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.