1

In the same vein as this question (and somewhat similar to this question), I am trying to insert anything (e.g. a word, character, or symbol) at the beginning of each wrapped line in a paragraph. However, the thing inserted should not be inserted before the first line of the paragraph. Here is a visual example of what I am aiming to do - where the red box is meant as a placeholder for whatever you want to insert:

enter image description here

Note that this is different than using a list, because the wrapped lines may have the line break in various places (based on things like badness, hyphenation, etc.). The goal is to have the item automatically inserted, regardless of the length of the paragraph.

I am personally using memoir document class and XeLaTex to compile, but hope that the answer to this can use any document class and pdfLaTex, etc.

The final requirement is to do this without an environment surrounding the text. For example, redefining the hanging indent glue to include something else.

A MWE without the symbols is:

\documentclass{memoir}

\usepackage{lipsum}

\begin{document}

\hangindent=4em\lipsum[1]

\end{document}

Question: Is it possible to redefine the glue at the beginning of the automatic line break (when wrapping) to include something like this? If not, is there another way to do so without wrapping the text in an environment (which is how the first question link above deals with it)?

  • it would be rather hard to do that on the main vertical list so an environment form would certainly be easiest, although that could be hidden in various ways, but why? – David Carlisle Apr 22 '18 at 18:10
  • @DavidCarlisle I am thinking this would be the 'best' way to handle answering this question. The problem is that the wrapped lines in that link are done in expex and I believe cannot accommodate environments or boxes. – whatisit Apr 22 '18 at 18:17
  • There is also a manual tikz-based approach which is asking if an automatic tikz way is possible, which is asked in this question. However, my question here seems like it might be the more fundamental way to approach the situation (i.e. not relying on other packages) - if it is even possible. – whatisit Apr 22 '18 at 18:28
  • at the primitive level tex has no way of doing this, so any solution is basically going to let the paragraph break as normal, work out where the lines went and then overlay the symbols, so you are always going to need to have access to the full text do do a second pass to add the symbols – David Carlisle Apr 22 '18 at 18:43
  • @DavidCarlisle thank you for clarifying this. I am OK with a second pass. Ignoring, for a moment, the ease with which it could be done, is a second-pass approach hypothetically possible? Or is this a brick-wall that cannot be overcome (within the restrictions that I mentioned in the OP)? – whatisit Apr 22 '18 at 19:13
2

So long as it doesn't have to page break.

\documentclass{memoir}

\usepackage{lipsum}

\begin{document}
\bgroup
\setbox0=\vbox{\hangindent=4em
  \lipsum[1]}%
\dimen0=\ht0
\noindent\rlap{\begin{minipage}[b]{4em}
  \strut
  \loop\ifdim\dimen0 > \baselineskip
    \advance\dimen0 by -\baselineskip
    \newline\null\hfill *
  \repeat
\end{minipage}}\box0
\egroup

\end{document}

demo

  • I was able to use this concept with expex and accomplished roughly the same thing now. This was a great starting point for it. After playing around with expex it doesn't seem to break mid-gloss, so page breaks are not a concern. – whatisit Apr 26 '18 at 22:35

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.