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 am slowly becoming more efficient with math environments and macros in TeX, but occasionally come across something where I'm not really sure what the best solution would be.

enter image description here

I wanted to hear from some experts what you think would be the most sensible approach (looks good and efficient to code) to making the above figure in LaTeX. I was initially thinking

  1. tabular using \multicolumn,
  2. TikZ; then
  3. array.

Not necessarily looking for someone to just write me a solution, but more of insight into your macro/environment approach and why.

share|improve this question
1  
I would use a tablular or array environment for the textual portion and tikz for the drawing. Use \tikzmark to mark the points where the drawing will need to know where things age. Plenty of examples of \tikzmark on this site. –  Peter Grill Sep 30 '12 at 23:09
1  
is it necessary or useful for the displacement "markers" to be positioned at different distances from the equilibrium points? this seems to me to be at least as much a diagram as something to be simulated by a table, and the distances, although not specific, are best shown as not uniform. if so, the picture environment might be appropriate. –  barbara beeton Oct 1 '12 at 12:53
    
I have yet to explore either the \tikzmark or picture options and will have fun with them this afternoon. Picture looks very straightforward and appears to work much like \tikzpicture. Thank you. –  Brazos Wolf Oct 2 '12 at 21:49

1 Answer 1

I tend to favour the ordinary use of environments like tabular or array, since it makes the solution easily portable without any bells or whistles. Simplicity perhaps.

Based on the display, I'm going for an array with one column for the left hand descriptors, and 12 columns for the arrangement on the right:

enter image description here

\documentclass{article}
\begin{document}
\[
  \begin{array}{r@{\quad}*{12}{c@{\mskip10mu}}}
    & n-2 & & n-1 & & & n & & & n+1 & & & n+2 \\
    \mbox{Equilibrium:} & \bullet & & \bullet & & & \bullet & & & \bullet & & & \bullet \\
    & \phantom{{\leftarrow}}{\!|\!}{\leftarrow} & a & {\rightarrow}{\!|\!}\phantom{{\rightarrow}} & \\
    \mbox{Displaced:} & \ooalign{$\bullet$\cr\hidewidth${|}$\hidewidth} & & {|} & & \bullet & {|} & & \bullet & {|} & & \bullet & \ooalign{$\bullet$\cr\hidewidth${|}$\hidewidth} \\
    & & & {\rightarrow}{\!|\!}\phantom{{\rightarrow}} & \makebox[0pt]{$u_{n-1}$} & \phantom{{\leftarrow}}{\!|\!}{\leftarrow} &
      {\rightarrow}{\!|\!}\phantom{{\rightarrow}} & \makebox[0pt]{$u_n$} & \phantom{{\leftarrow}}{\!|\!}{\leftarrow} &
      {\rightarrow}{\!|\!}\phantom{{\rightarrow}} & \makebox[0pt]{$u_{n+1}$} & \phantom{{\leftarrow}}{\!|\!}{\leftarrow}
  \end{array}
\]
\end{document}
share|improve this answer
    
It's verbose, but I like the straightforwardness of using just the array environment--it's easy for a newbie like me to understand. Is phantom the only solution for properly aligning tags under bullets? –  Brazos Wolf Oct 2 '12 at 21:42
    
Also, why did you use \makebox for the $u_{n}$ tags and not \multicolumn or something like that? –  Brazos Wolf Oct 2 '12 at 21:43
1  
@BrazosWolf: No, you could probably also use a zero-width box for the one side that has an arrow. Something like \rlap{$\leftarrow$} and/or \llap{$\rightarrow$} without the accompanying \phantom (not tested). The zero-width box (\makebox[0pt]) allows the contents of box to be larger yet TeX still sees it as a 0pt width box. So it helps condense things, since there's already a \arraycolsep gap between the columns. –  Werner Oct 2 '12 at 21:46

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.