Why your solution bugs
\pstart…\pend must contain only normal text. Not mathematical display, and not \vskip. Any entry like this perturbate the way reledmac/reledpar split lines, and so the alignment.
Principle of my solution
We will use a \setindent but OUTSIDE of the \pstart…\pend. To do that, we use the fact that in parallel typesetting, reledpar stores the \pstart…\pend content in numbered vbox. So we will copy the content of the box, and using some TeX' hacks on box mechanism, get the last line of the vbox. And then, using new code provide by David Carlisle, get the natural width of the lastline.
Other inhancement
As explained by chat, you should not use \maketaletter
without a corresponding \makeatother
. And if you use many time command with @ in the name, you should wrap it in an other command. I have created a \myindent
command.
So, final code
\documentclass{article}
\usepackage{reledmac}
\usepackage{reledpar}
\usepackage{lipsum}
\makeatletter
% My new setindent
\def\setindent{%
\ifledRcol
\setbox0=\expandafter\copy\csname l@dRcolrawbox\the\l@dnumpstartsR\endcsname%On rightside, copy the content of last \pstart…\pend pair
\else
\setbox0=\expandafter\copy\csname l@dLcolrawbox\the\l@dnumpstartsL\endcsname%On leftside, copy the content of last \pstart…\pend pair
\fi
\expandafter\newdimen\csname l@\the\l@dnumpstartsR\endcsname%
\setbox0=\vbox{%
\parindent=0pt%
\setbox1=\vsplit0 to\baselineskip%Get only the last line in vbox0
\unvbox0%Unvbox it
\setbox0=\lastbox%Get the last line on the form of hbox
\setbox0=\hbox{\unhbox0\unpenalty\unskip\unskip}
\global\dimen\@ne=\wd0%
}%We do it in a setbox in order to print nothing
}
% Avoid to use command with @ in the main text
\newcommand{\myindent}{\noindent\hskip\dimen\@ne}% I don't understand why we need such correction of 20pt !!! But it is not linked to reledmac, as a test of your \setindent outside of any reledmac context can prove
\makeatletter
\begin{document}
\begin{pages}
\begin{Leftside}
\beginnumbering
\pstart
\lipsum*[1]
\pend
\pstart
\lipsum*[2]
\pend
\pstart
\lipsum*[3]
\pend
\pstart
\lipsum*[4]
\pend
\endnumbering
\end{Leftside}
\begin{Rightside}
\beginnumbering
\pstart
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?
\pend
\setindent
\pstart
\myindent\lipsum*[6]%
\pend
\setindent
\pstart
\myindent
\lipsum*[7]%
\pend
\setindent
\pstart
\myindent\lipsum*[8]
\pend
\setindent
\endnumbering
\end{Rightside}
\end{pages}
\Pages
\end{document}
A variant
Maybe instead of
\newcommand{\myindent}{\noindent\hskip\dimen\@ne}
Do
\newcommand{\myindent}{\noindent\ \hskip\dimen\@ne}
It will add a space, as required after a final dot.
!!!!
here\setindent
are commented out.