[comp.text.tex] Put something above a word ?

esink@turia.dit.upm.es (03/20/91)

I need a way, I don't care if it's TeX or LaTeX, to align combinations
of letters directly above or below each other.  I'm envisioning a
macro, but then I don't know a lot about TeX/LaTeX.

Something like this :

     T\above{D#}wist and S\above{G#}hout, s\above{C#}hout shout shout

should produce :

     D#        G#     C#
     Twist and Shout, shout shout shout

The purpose is to put music chord names above words of a song.  I need
the ability to put chord names of arbitrary length (G#min7 for example),
and the ability to put them at arbitrary places (ie in the middle of a
word).

My understanding of TeX is that it can do anything, so the question
should always be 'How can I do it ?' instead of 'Can I do it ?'...

So, How can I do this ?

Thanks in advance,

Eric
Eric W. Sink                     | Putting the phrase      |All opinions
Departamento de Telematica       | "Frequently Asked"      |are mine and
Universidad Politecnica de Madrid| in your kill file is    |not necessarily
esink@turia.dit.upm.es           | not recommended.        |yours.

haccme@milton.u.washington.edu (Thomas Ridgeway) (03/21/91)

Regarding putting musical chord notation above the lyrics for a song:

% TeX code begins here
% quick hacks for above-line display of short bits of text
\newdimen\bangback
\def\bangup#1{\setbox0\hbox{#1}\bangback=\wd0\raise\baselineskip\box0\hskip -\bangback}

Suppose that we are just running along in the midst of a paragraph, and we 
want to do what you propose with setting some chord notation above the text:
this is the text with o\bangup{G\#}verset bits of stuf\bangup{A}f.  We would
just go ahead and bang it up there.

Probably most likely you would want to put it into a display line, rather
than into a paragraph, or along with typeset music.

\centerline{I don't think th\bangup{B$\flat$}at the display line is a problem}

\noindent but there is just no telling what kind of interaction you might get
with the macros that would be setting the music (if that is what one were doing).

I am not too sure about the merits of the negative hskip versus another way
of hiding the width; mostly what we want to do is prevent the raised portion
from becoming separated from its mainline text at the beginning or end of 
a line.  Also, raising the chords an entire baselineskip above the mainline
may be just a tad too far, but this ought to give you something to get started
with.


\bye
Tom

form@pyuxe.UUCP (thomas a rowe) (03/21/91)

I've just been writing a set of macros to produce a songbook (lyrics and
chords).  The macro to place chords above lyrics is (in LaTeX notation):

	\newcommand{\Ch}[2]{\vbox{\hbox{ }\hbox{bf{#1}}\hbox{#2}}}

	Paramater:  1 - chord to be set;
		    2 - sylable over which chord is to be right justified.

The rationale behind the macro is:  A chord is normally attached to a syllable
or syllables.  A chords placement has musical/timing significance.  Hence the
design.  I force the chords bold so that they're more easily read.

As it stands the macro has one bug:  When the macro is the first character in
a paragraph, it forces a newline after the syllable.

Christopher Rath
613-594-3026

rcj@caen.engin.umich.edu (R o d Johnson) (03/22/91)

In article <1139@pyuxe.UUCP> form@pyuxe.UUCP (71133-Christopher Rath) writes:
>I've just been writing a set of macros to produce a songbook (lyrics and
>chords).  The macro to place chords above lyrics is (in LaTeX notation):
>
>	\newcommand{\Ch}[2]{\vbox{\hbox{ }\hbox{bf{#1}}\hbox{#2}}}
>
>	Paramater:  1 - chord to be set;
>		    2 - sylable over which chord is to be right justified.
 . . .
>As it stands the macro has one bug:  When the macro is the first character in
>a paragraph, it forces a newline after the syllable.

I think you need to put a \leavevmode in there somewhere to avoid this.

As it stands, the macro has another, if not bug, undesirable feature.
If your #2 has no ascenders (e.g., the word "one") the chord is going
to be lower than it is over words with ascenders.  You need to put a
\strut in both \hboxes to forestall this.  A properly defined strut
will make the first \hbox{ } unnecessary as well.

--
 Rod Johnson  *  rjohnson@vela.acs.oakland.edu  *  (313) 650 2315 

  "House, bridge, well, gate, jug, olive tree, window"  --Rilke

jg@prg.ox.ac.uk (Jeremy Gibbons) (03/22/91)

> I need a way, I don't care if it's TeX or LaTeX, to align combinations
> of letters directly above or below each other.  

Try

   \def\above#1{\leavevmode\raise2ex\rlap{#1}}

(untested!)

Jeremy

*-----------------------------------------------------------------------*
|  Jeremy Gibbons (jg@uk.ac.oxford.prg)   Funky Monkey Multimedia Corp  |
*-----------------------------------------------------------------------*