views:

48

answers:

1

I've created latex macro to typeset guitar chords diagrams(using picture environment). Now I want to make diagrams of different appear in good looking grid when typeset one next to each other as the picture shows:

The picture. (on the picture: Labeled "First" bad layout of diagrams, labeled "Second" correct layout when equal number of diagrams in line)

I'm using \hspace to make some skips between diagrams, otherwise they would be too near to each other. As you can see in second case when latex arrange pictures in so that there is same number of them in each line it works. However if there is less pictures in the last line they become "shifted" to the right. I don't want this.

I guess is because latex makes the space between diagrams in first line a little longer for the line to exactly fit the page width. How do I tell latex not to resize spaces created by \hspace ? Or is there any other way ?

I guess I cannot use tables because I don't know how many diagrams will fit in one line...

This is current state of code:

\newcommand{\spaceForChord}{1.7cm}

\newcommnad{\chordChart}[1]{%
  %calculate dimensions xdim and ydim according to settings
  \begin{picture}(xdim, ydim){%
    %draw the diagram inside defined area
  }%
  \hspace*{\spaceForChord}%
  \hspace*{-\xdim}%
}%

%end preambule and begin document
\begin{document}
First:\\*
\\*
\chordChart{...some arguments to change diagram look...}
\chordChart{...some arguments to change diagram look...}
\chordChart{...some arguments to change diagram look...}
\chordChart{...some arguments to change diagram look...}
\chordChart{...some arguments to change diagram look...}
%...above line is repeated 12 more times to produce result shown at the picture
\end{document}

Thanks for any help.

+1  A: 

A long shot, since I can't easily recreate your situation: would wrapping a flushleft environment around your \chordCart be of any help?

I.e.,

First:\\*
\begin{flushleft}
\chordChart{...some arguments to change diagram look...}
...
\end{flushleft}

Second:\\*

If your hypothesis is correct and LaTeX is indeed trying to stretch spaces to justify lines, then the above should solve your problem by turning off justification on the right.

Florent
Thank you very much, it solved the problem. It was very simple but just didn't come to my mind. Sorry for silly question... And now one more: how do I mark this question answered? :)
drasto
You're very welcome. As for accepting an answer, have a look at: http://meta.stackoverflow.com/questions/5234/accepting-answers-what-is-it-all-about.
Florent