3

I'm making a ukulele songbook and i used this code to make chords rise above the text. but it makes a small space before the word (when you put chords above). Do you know how to fix it?

\newcommand{\ch}[1]{%
  \makebox[-6pt][c]{%
    \raisebox{22pt}[24pt]{~~{\setlength{}\huge\textbf{#1\hspace{-0.33in}}} }
  }
}
4
  • Welcome to TeX.SX! Sometimes it's better to post a full example document, such that users who want to help you can start 'immediately'. – user31729 Dec 4 '14 at 22:34
  • 1
    Do you had a look into the guitar package? Perhaps it might help for the ukulele as well. – user31729 Dec 4 '14 at 22:36
  • 3
    Seems is if you have spurious spaces in the \newcommand definition. Try adding a % immediately after the first {, remove the space following the }}} and add a % at the end of that line. i.e., use \newcommand{\ch}[1]{\makebox[-6pt][c]{\raisebox{22pt}[24pt]{~~{\setlength{}\huge\textbf{#1\hspace{-0.33in}}}}}}. – Peter Grill Dec 4 '14 at 22:42
  • 3
    \setlength{}\huge must generate errors? what is it intended to do, you have not specified which length to set or a value? – David Carlisle Dec 4 '14 at 22:55
1
\documentclass{article}

\makeatletter
\newcommand{\ch}[1]{%
  \leavevmode\@bsphack
  \raisebox{2ex}{\makebox[0pt][l]{\small\bfseries\strut#1}}\nolinebreak
  \@esphack
}
\makeatother

\begin{document}

\begin{verse}
\ch{G}.. Mamma take this \ch{D}badge from \ch{Am7}me\\
\ch{G}.. I can't use\ch{D} it any \ch{C}more\\
\ch{G}.. It's getting \ch{D}dark, too dark to \ch{Am7}see\\
\ch{G}.. Feels like I'm \ch{D}knocking on heaven's \ch{C}door\\
\end{verse}

\end{document}

enter image description here

1

If anyone wants to do simple chords here are the commands,

\newcommand{\ch}[1]{%
  \makebox[-6pt][c]{%
    \raisebox{22pt}[24pt]{~~{\huge\textbf{#1\hspace{-0.33in}}} }
  }
}

Then if you write a song like this:

\ch{G}.. Mamma take this \ch{D}badge from \ch{Am7}me\\
\ch{G}.. I can't use\ch{D} it any \ch{C}more\\
\ch{G}.. It's getting \ch{D}dark, too dark to \ch{Am7}see\\
\ch{G}.. Feeles like I'm \ch{D}knocking on heaven's \ch{C}door\\

It will generate a result like:

enter image description here

2
  • Uh, \setlength{}\huge becomes \huge\relax, so you probably want to remove \setlength{} which does nothing (and is wrong). – egreg Dec 6 '14 at 13:22
  • Fixed it. Sorry, it was a leftover i forgot. – Ráďa Dec 6 '14 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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