I have the following code to add chords over the lyrics of a song:

```
\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{fontenc}
\usepackage{xcolor}
%Page Margins:
\usepackage[headheight=130pt,tmargin=130pt,headsep=50pt, a4paper, total={6in, 9in}]{geometry}

%Line Spacing, Paragraph indentation and Paragraph Spacing
\renewcommand{\baselinestretch}{1}
\setlength{\parindent}{0em}
\setlength{\parskip}{0.2em}

\newcommand\chord[2][l]{\makebox[0pt][#1]{\color{rgb,232:red,232;green,0;yellow,0}\begin{tabular}[b]{@{}l@{}}#2\\\mbox{}\end{tabular}}}

\begin{document}

This is a \chord{Am}li\chord{B}ne of text \chord{C}with chords\chord{Am}\chord{B}

\end{document}

```

which generates (I use pdflatex):
[![Generated line](https://i.stack.imgur.com/BCDQd.png)](https://i.stack.imgur.com/BCDQd.png)

The problem is obvious: when chords are too close together they overlap. Is there a way to make the chords move to the right automatically just enough so that they do not overlap? I don't mind if the chord is not exactly over the spot where they are placed in the code, as long as they are clearly visible. Any suggestions are welcome!