4

I have right-aligned paragraphs and want to float text around a little text snipped, which should be placed in the first line of the paragraph at the right side.

enter image description here

How can I achieve this? The LaTeX code with the text snipped at the end of the paragraph (thanks to David Carlisle https://tex.stackexchange.com/a/144263/40802):

\documentclass[c6paper,DIV=14,pagesize=auto,fontsize=8pt]{scrbook}
\newcommand\zz[2]{\par{\normalsize\strut\textbf{#1} #2} \hfill\ignorespaces}
\begin{document}
\begin{flushright}\tiny

\zz{I}{Some Name}Lorem ipsum dolor sit amet, consectetur adipiscing \textit{\textbf{some comment}}
\zz{II}{Another Name} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum elit \textit{\textbf{some comment}}
\zz{IIa}{Variant of Another Name}Lorem ipsum dolor sit amet, consectetur  adipiscing elit. \textit{\textbf{some comment}}
\end{flushright}
\end{document}
6

\parshape is your friend.

enter image description here

\documentclass[c6paper,DIV=14,pagesize=auto,fontsize=8pt]{scrbook}
\newcommand\zz[3]{%
\sbox0{ \textit{#3}}%
\par\parshape 2 0pt \dimexpr \linewidth-\wd0 0pt \linewidth
\leavevmode\rlap{\kern\linewidth\llap{\usebox0}}%
{\normalsize\strut\textbf{#1} #2} \hfill\ignorespaces}
\begin{document}
\begin{flushright}\tiny

\zz{I}{Some Name}{comment1}Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\zz{II}{Another Name}{some comment} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum elit
\zz{IIa}{Variant of Another Name}{}Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{flushright}
\end{document}
  • Great, thank you very much! Is there a way to control the space between box0 and the text left of it? And is it possible to control this conditionally? Like "if no line break occurs use small space, else make the margin bigger"? – seflue Nov 10 '13 at 21:07
  • 1
    you can control the space by replacing \sbox0{ \textit{#3}}% by \sbox0{\hspace{2cm}\textit{#3}}% or whatever length you want, you can't make it conditional as \parshape sets the shape with fixed lengths before linebreaking happens (it is the target length for linebreaking) – David Carlisle Nov 10 '13 at 21:44
0

I actually wanted to ask nearly the same question as the OP, but I had a hacky solution using bidirectional layout in advance. Maybe someone can use it (uses lualatex by default):

\documentclass{article}
\usepackage{lipsum}

\def\putatend#1{%
\luatextextdir TRT {\luatextextdir TLT\hfill #1\unskip}%
\luatextextdir TLT%
}

%nearly the same with pdflatex:
%\TeXXeTstate=1
%\def\putatend#1#2{%
%\beginR {\beginL #1 \endL} \hfill {\beginL #2 \endL}\endR%
%} 

\begin{document}
\putatend{end} \lipsum
%\putatend{end}{\lipsum}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.