2

When adding afterwards a character to a enumeration I do not succeed by going back with \vspace: The character C in the MWE is positioned too "high". Is there a possibility to achieve this? (I need to do this because I want to define an environment including enumerations with a symbol at the end.)

\documentclass{article}
  
\begin{document}

\begin{enumerate}
\item A
\item B
\end{enumerate}
\vspace{-2\baselineskip}
\hfill C

\end{document}
6
  • 1
    What you want is not clear. Should C be on the same line as B?
    – Bernard
    Nov 14, 2020 at 16:29
  • I don't think this is the easiest way to define an environment including enumerations with a symbol at the end. Is this more or less the same question as your last one? Do you need another solution?
    – Vincent
    Nov 14, 2020 at 16:33
  • @Bernard Yes, C should be on the same line as B.
    – ubuntuuser
    Nov 14, 2020 at 17:20
  • @Vincent Yes, it's the same problem. I answered there to your suggestion.
    – ubuntuuser
    Nov 14, 2020 at 17:21
  • @Teepeemm That question is also mine, I thought another formulation may help.
    – ubuntuuser
    Nov 14, 2020 at 17:22

2 Answers 2

3

You can define an environment that automatically adds “C” at the end of the last line or on the next line if there's no room, but keeping it right flush.

Restriction: no blank line before \end{qenumerate}.

\documentclass{article}

\newenvironment{qenumerate}
 {\enumerate}{\finalsymbol\endenumerate}

\newcommand{\finalsymbol}{%
  {\unskip\nobreak\hfill\penalty50\hskip1em\null\nobreak
   \hfill\mbox{\normalfont C}% <--- or whatever you want
   \parfillskip=0pt \finalhyphendemerits=0 \par}%

}

\begin{document}

\begin{qenumerate}
\item text text text text text text text text text text text text
      text text text text text text text text text text text text
      text text text text text text text text text text text text
\item text text text text text text text text text text text text
      text text text text text text text text text text text text
      text text text text text text text text text text text text
\end{qenumerate}

\begin{qenumerate}
\item text text text text text text text text text text text text
      text text text text text text text text text text text text
      text text text text text text text text text text text text
\item text text text text text text text text text text text text
      text text text text text text text text text text text text
      text text text text text text~aaaaaa
\end{qenumerate}

\end{document}

enter image description here

0

You can simply adjust the \vspace to any decimal number you want. You can also change the unit, for example, \vspace{-0.5cm}.

enter image description here

\documentclass{article}
  
\begin{document}

\begin{enumerate}
\item A...
\item B...
\end{enumerate}
\vspace{-0.9\baselineskip} % change to anything you want
\hfill C

\end{document}
1
  • 3
    Welcome to TeX.SE. This would work, but would involve a lot of trial and error for OP, and might even change with changing font sizes. I don't think I would recommend this approach.
    – Teepeemm
    Nov 14, 2020 at 16:40

Not the answer you're looking for? Browse other questions tagged .