Align minipage to baseline of first or last line inside minipage?

The [t] and [b] optional arguments of minipage already use the baselines of the first and last line, and not the top or bottom of the surrounding box. AFAIK most of such vertical positioning options in LaTeX address baselines. Here three minipages with [t], [c] (or without) and [b] options (code below):

Result

If this wouldn't be the case I would use \raisebox{\dimexpr-\height+\ht\strutbox\relax}{<content>} and \raisebox{\dimexpr\depth-\dp\strutbox\relax}{<content>} for the first and last baseline, respectively. This depends on the content, but would be accurate if both lines contain a \strut.


Update:

About the issue with \color: This macro apparently adds some vertical space because at the beginning of minipage TeX is still in vertical mode. To avoid this use \leavevmode before \color (as \textcolor does internally). This will change to horizontal mode and avoid the misalignment. Added a \strut before \color should actually do the same, because it also starts horizontal mode.


\documentclass{article}

\usepackage{lipsum}

\begin{document}

before
\begin{minipage}[t]{1cm}
    First\\
    Middle\\
    Last
\end{minipage}
between
\begin{minipage}[c]{1cm}
    First\\
    Middle\\
    Last
\end{minipage}
between
\begin{minipage}[b]{1cm}
    First\\
    Middle\\
    Last
\end{minipage}
after

\end{document}