3

This is an Italian edition of "Il Milione" by Marco Polo. Within this edition I have the main codex (main text), the “optimum”, and other codices from other documentary sources (Comment 1 and Comment 2) that enrich the choosen codex with other details that are missing from the original text.

enter image description here

I would like to replicate a similar pattern in LaTeX using something similar with this code:

% Main Text
Non hanno ferro per fare aguti;
%  Comment 1
\begin{UnknownEnvironment}
 \textit{Cas.} [ma fano cavechie de legno e con quele conficano le soe nave;]
\end{UnknownEnvironment}
% Please note that at this point, the main text continues
% below right the word “aguti”
ed è grande pericolo a navicare \dots Egli è vero che vi viene un vento$^2$ talvolta la sate,
% Comment 2
\begin{UnknownEnvironment}
 \textit{Pad.} [de verso uno destro de sabione ch'é atorno de quel punto]
\end{UnknownEnvironment}
% Even in this case, the main text continues below right “aguti”
di verso lo sabbion, con tanto caldo che \dots 

More clearly, I want that all the comments and all the main text stays in the main part of the page, and that the notes are both reentrant, and both allow the main text to continue from the same point where it was break.

Is there a package that does both an indentent comment inside an environment and that, after such comment, the main text continues below right the next word? Thanks in advance!

1
  • So, it's more like to use PositionText when the main text starts again as in tex.stackexchange.com/a/35667/30524, but I don't now how to set anchors that save the actual horizontal position of the last glyph within the main text (as in align). – jackb Aug 31 '16 at 15:47
4

If you want justified text you can use the zref-savepos package to store the location where you end the text before a comment. Be aware that it needs some compilations until all the references are resolved:

\documentclass{article}
\usepackage[italian]{babel}
\usepackage{zref-savepos}
\usepackage{changepage}
\newcounter{mycomment}

\newenvironment{UnknownEnvironment}
 {\unskip\stepcounter{mycomment}\zsavepos{endpar\the\value{mycomment}}%
    \par\bigskip%
    \bfseries%
    \begin{adjustwidth}{3cm}{0cm}}
 {\end{adjustwidth}
  \par\bigskip
  \noindent\hspace*{\dimexpr\zposx{endpar\the\value{mycomment}}sp-\oddsidemargin-1in}\ignorespaces}
\begin{document}

 Main Text
Non hanno ferro per fare aguti;
%  Comment 1
\begin{UnknownEnvironment}
 \textit{Cas.} [ma fano cavechie de legno e con quele conficano le soe nave;]
\end{UnknownEnvironment}
ed è grande pericolo a navicare \dots Egli è vero che vi viene un vento$^2$ talvolta la sate,
% Comment 2
\begin{UnknownEnvironment}
 \textit{Pad.} [de verso uno destro de sabione ch'é atorno de quel punto]
\end{UnknownEnvironment}
% Even in this case, the main text continues below right �aguti�
di verso lo sabbion, con tanto caldo che \dots

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur imperdiet ante a turpis pulvinar, quis pharetra lorem finibus. Sed iaculis ritus sed molestie elementum. Duis porta maximus velit quis imperdiet. Sed nec lacis vitae nisl rutrum accumsan. Nam molestie purus hendrerit ex tempus volutpat. Donec luctus,
\begin{UnknownEnvironment}
  Some example text
\end{UnknownEnvironment}
nulla nec molestie eleifend, lectus sapien rhoncus nisl, id maximus diam ex sed metus. Present volutpat eu mi in vehicula. In lobortis vitae magna at finibus. Phasellus tempor urna eros, consequat blandit sem rhoncus a. Aliquam erat volutpat. Aliquam venenatis maximus felis, vel feugiat mauris tincidunt mattis. Maecenas accumsan metus nec tortor tempor maximus.%
\end{document}

enter image description here

4

Here is a solution using the linegoal-package. It does have a big flaw, in that it only works with \raggedright-text. I am sure there is a smart solution to get around this, though.

The indentation of the created environment is created with changepage-package, with the adjustwidth-environment. There are of course other alternatives.

Output

enter image description here

Code

\documentclass{article}
\usepackage{linegoal}
\usepackage{changepage}

\newlength{\previousLine}
\newenvironment{UnknownEnvironment}
  {%
    \setlength{\previousLine}{\linewidth}%
    \addtolength{\previousLine}{-\linegoal}
    \par\bigskip%
    \bfseries%
    \begin{adjustwidth}{3cm}{0cm}%
  }
  {%
  \end{adjustwidth}
  \par\bigskip%
  \hspace*{\previousLine}%
  }
\raggedright
\begin{document}

 Main Text
Non hanno ferro per fare aguti;
%  Comment 1
\begin{UnknownEnvironment}
 \textit{Cas.} [ma fano cavechie de legno e con quele conficano le soe nave;]
\end{UnknownEnvironment}%
% Please note that at this point, the main text continues
% below right the word �aguti�
ed è grande pericolo a navicare \dots Egli è vero che vi viene un vento$^2$ talvolta la sate,
% Comment 2
\begin{UnknownEnvironment}
 \textit{Pad.} [de verso uno destro de sabione ch'é atorno de quel punto]
\end{UnknownEnvironment}%
% Even in this case, the main text continues below right �aguti�
di verso lo sabbion, con tanto caldo che \dots

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur imperdiet ante a turpis pulvinar, quis pharetra lorem finibus. Sed iaculis ritus sed molestie elementum. Duis porta maximus velit quis imperdiet. Sed nec lacis vitae nisl rutrum accumsan. Nam molestie purus hendrerit ex tempus volutpat. Donec luctus,
\begin{UnknownEnvironment}
  Some example text
\end{UnknownEnvironment}%
nulla nec molestie eleifend, lectus sapien rhoncus nisl, id maximus diam ex sed metus. Present volutpat eu mi in vehicula. In lobortis vitae magna at finibus. Phasellus tempor urna eros, consequat blandit sem rhoncus a. Aliquam erat volutpat. Aliquam venenatis maximus felis, vel feugiat mauris tincidunt mattis. Maecenas accumsan metus nec tortor tempor maximus.%
\end{document}
2
  • yeah, removed that from answer now. Just something left from editing. – Runar Aug 31 '16 at 16:25
  • … for the margin part, I used \begin{addmargin}[3cm]{0cm} and \end{addmargin} within the definition of the environment. – jackb Aug 31 '16 at 16:31

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.