3

I've tried to mix text and images in Optex, but the solution is far from perfect. It throws an error -- Missing } inserted. Besides, I'm quite unsure about whether the use of \valign and \vtop (unabashedly copied from here) is the best option in this case.

enter image description here

\putpic 10cm -4.2cm 6cm \nospec {S10.jpg}

\hangindent=-6.5cm \hangafter=0  
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget pretium urna, id congue tortor. Praesent sit amet malesuada est. Curabitur ut euismod libero. Morbi quis turpis eget tortor faucibus accumsan sed non dolor. Sed eu enim gravida, maximus dui a, ornare leo. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent scelerisque lectus metus, tempus maximus elit auctor vel. Ut tincidunt quam quis scelerisque venenatis. Suspendisse non vulputate sem. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Curabitur odio magna, venenatis vitae hendrerit eu, laoreet quis sem.

\puttext 9.9cm -1.5\baselineskip{
\valign{%
    \vtop{%
    \hsize60mm
    \raggedright\parindent0pt\tolerance9999
    #
    }
\cr
    \caption/f A colorful bird bathing in the rain.\cr}
}

\hangindent=-6.5cm \hangafter=-2
Cras urna ante, dictum vitae convallis eu, imperdiet pellentesque enim. Mauris lectus elit, dapibus ut augue nec, consectetur interdum justo. Proin sed auctor tellus. Proin in mauris nulla. Praesent tempor lectus nisi, at feugiat lectus dapibus vitae. Donec aliquam eu mi ut consectetur. Proin id consectetur lacus, quis condimentum diam. 


\bye
2
  • @wipet will help soon! :)
    – JamesT
    Commented Oct 17, 2022 at 22:35
  • 1
    @JamesT, I'm sure he will, although I think the matter is more akin to a plain text issue than a specific optex issue.
    – user574859
    Commented Oct 17, 2022 at 23:37

1 Answer 1

5

IMHO, the \vadjust is not needed here, you want to put only \vtop at desired place.

The problem is at the end of the \caption text. It must be finalized by \cskip or \vskip... or \_par etc. But explicit \_par doesn't work in \puttext now (I'll remove this bug soon), so use \cskip as a \caption text separator.

%\putpic 10cm -4.2cm 6cm \nospec {S10.jpg} % I have no your picture of the bird.

\hangindent=-6.5cm \hangafter=0  
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget pretium urna, id

\puttext 10cm -1\baselineskip{%
    \vtop{
    \hsize60mm
    \raggedright\parindent0pt\tolerance9999
    \caption/f A colorful bird bathing in the rain.
    \cskip}%
}

\hangindent=-6.5cm \hangafter=-2
Cras urna ante, dictum vitae convallis eu, imperdiet pellentesque enim. Mauris lectus elit,

\bye

Better solution is to use single \puttext with the picture and caption together. I created \vtop started by \kern0pt in order to set the y-position by the top of the picture (see 0pt in the \puttext parameter).

\puttext 10cm 0cm {\vtop{\kern0pt
   \hsize=6cm \picw=\hsize
   \inspic {example-image.pdf}  % use your bird here.
   \medskip
   \iindent=0pt  % we don't want to have caption narrower
   \caption/f A colorful bird bathing in the rain.
   \cskip
}}
\nobreak

\hangindent=-6.5cm \hangafter=0  
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget pretium urna, id

\hangindent=-6.5cm \hangafter=-2
Cras urna ante, dictum vitae convallis eu, imperdiet pellentesque enim. Mauris lectus elit,

\bye

You can say \let\_narrowlastlinecentered=\ignoreit just before \caption if you don't want centered formatting.

1
  • Thank you so much! It's much cleaner now.
    – user574859
    Commented Oct 18, 2022 at 9:56

You must log in to answer this question.

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