Text FormattingForce spacing at the beginning of a line / Chords, Lyrics

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
ratnanil
Posts: 3
Joined: Mon Nov 19, 2012 2:19 am

Force spacing at the beginning of a line / Chords, Lyrics

Post by ratnanil »

Hello People!

My very first post, please forgive any sins I might commit due to my lack of board-experience :-)

Here's my question: I would like to force any given amount of spaces in Latex. "\ " seems to work really well, except at the beginning of a line. Is there a way to force spacing at the beginning of a line without using any additional packages or vspace?

Here's the background: I'd like to import Song Lyrics and Chords into Latex without much work, ie without much tedious reformatting of the text to make it Latex-Suitable.

The standard method of displaying Song Lyrics and Chords on the net is using a monospaced font and having the lyrics on one line, and the chords with the appropriate amount of spacings on the line above. "The appropriate amount of spaces" are needed to make the chord align with the word where the chord change takes place. See an example here: http://tabs.ultimate-guitar.com/t/tenac ... te_crd.htm

So all I need to do if I want to import this song into Latex is to replace all " " with "\ " and the linebrakes with "\\" (as you know these steps can be easily done with a standard "search and replace" function).

And this is where the problem starts: Some lines don't start with a chord change, ie don't have a chord in the beginning of the line (see line "One and one make two, two and one make three"). The "\ " command doesn't seem to work on those lines. Does anybody have any suggestions? A spacing-force-command that does work at the beginning of a line? Or an invisible sign at the beginning of the line to trick Latex into thinking the spacing is not the first character of the line?

Thanks in advance!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Force spacing at the beginning of a line / Chords, Lyrics

Post by cgnieder »

Hi ratnanil,

Welcome to the LaTeX community!

The easiest way would be to pick one of the packages designed for things like this. guitar maybe:

Code: Select all

\documentclass{article}
\usepackage{guitar}

\begin{document}

\begin{guitar}
[Am]This is the greatest and best song in the world...   Tribute.
[Am]Long time ago me and my brother Kyle here,
[Am]We was hitchhikin' down a long and lonesome road.
[Am]All of a sudden, there shined a shiny demon...
[Am]In the middle of the road.
[Am]And he said:
``[A5 (Palm-Muted)]Play the best song in the world, or I'll eat your souls.''
[Am]Well me and Kyle, we looked at each other,
[Am]And we each said... ``Okay''


[Am]And we played the first thing that [G]came to our heads,
[F]Just so happened to be,
[Am]The Best Song in the [G]World, it was [F]The Best
Song in the World.


[D]Look into my eyes and it's [F]easy to see
One and [C]one make two, two and [G]one make three,
It was [F]destiny.\\
[D]Once every hundred-thousand [F]years or so,
When the [C]sun doth shine and the [G]moon doth glow
And the [F]grass don't grow...
\end{guitar}

\end{document}
Regards
site moderator & package author
ratnanil
Posts: 3
Joined: Mon Nov 19, 2012 2:19 am

Force spacing at the beginning of a line / Chords, Lyrics

Post by ratnanil »

Thank you Clemens, for your welcome and your answer!

You're right, the method you propose would definitely be the cleanest way to solve this. The thing is, it is tedious work to transcribe hundreds of songs from:

Am
This is the Greatest Song...


to

[Am]This is the Greatest song...

Or is there a way automate this? Quasi: "Take the characters from one line, put them im brackets and place them in the equivalent position in the line below". Other than programming the software on my own, I wouldn't know how to automate this..

To my original question, how I can force spacing at the beginning of a line, you have no solution?

Thank you in advance,

Nils
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Force spacing at the beginning of a line / Chords, Lyrics

Post by cgnieder »

In this case a verbatim-like environment might be the best solution. I'd recommend listings for that:

Code: Select all

\documentclass{article}
\usepackage{listings}
\begin{document}

% standard LaTeX:
\begin{verbatim}
Am                                 G
And we played the first thing that came to our heads,
F
Just so happened to be,
Am                   G             F
The Best Song in the World, it was The Best Song in the World.
\end{verbatim}

% listings:
\begin{lstlisting}[columns=flexible]
Am                                 G
And we played the first thing that came to our heads,
F
Just so happened to be,
Am                   G             F
The Best Song in the World, it was The Best Song in the World.
\end{lstlisting}

\lstnewenvironment{song}{\lstset{columns=flexible}}{}

\begin{song}
Am                                 G
And we played the first thing that came to our heads,
F
Just so happened to be,
Am                   G             F
The Best Song in the World, it was The Best Song in the World.
\end{song}

\end{document}
Regards
site moderator & package author
ratnanil
Posts: 3
Joined: Mon Nov 19, 2012 2:19 am

Re: Force spacing at the beginning of a line / Chords, Lyric

Post by ratnanil »

Hello Clemens! Thank you for your quick reply... I will give this a try!
Houghte
Posts: 1
Joined: Mon Sep 05, 2016 12:36 pm

Force spacing at the beginning of a line / Chords, Lyrics

Post by Houghte »

hello! this is awesome... i was just looking for my answer and here it is... thanks a lot...
now i am going to listen some songs
Post Reply