latexalignment

Latex alignment


I have a text in Latex that I would like to align centrally, but some of the rows have a checkmark at the end that I would like to exclude from the alignment, i.e. I would like to achieve something like that:

enter image description here

I tried to use \hspace{1em} at the beginning of the line, which seems to work, but is not really elegant.

Current code:

\documentclass[a4paper,12pt]{article}

\usepackage[svgnames]{xcolor}
\usepackage{bbding}

\begin{document}
\centering
\hspace{1.5em} lorem ipsum {\color{OliveDrab}\hspace{0.5em}\Checkmark}

dolor sit amet consectetur

adipiscing elit
\end{document}

Solution

  • You could place the checkmark in a box of zero width:

    \documentclass[a4paper,12pt]{article}
    
    \usepackage[svgnames]{xcolor}
    \usepackage{bbding}
    
    \begin{document}
    \centering
    lorem ipsum\makebox[0pt][l]{ \color{OliveDrab}\hspace{0.5em}\Checkmark}
    
    dolor sit amet consectetur
    
    adipiscing elit
    \end{document}
    

    enter image description here