第一次近似

第一次近似

我想找到一種方法來水平對齊文件中的任意兩個或多個隨機位置(但可能在同一頁上或彼此距離不太遠)。它有點像表格的第二列,但是:

  1. 「行」可以用任意數量的任何東西分隔。 (表格可以在行之間拆分。)
  2. 要對齊的點並不總是被視為屬於表格的行或單元格,因為它們可以出現在正常段落的中間,而段落的其餘部分不會受到此對齊的影響。

如何使以下範例中的所有項目符號對齊(用空格替換減號)?

(1) 這句話缺少 X。

中間有一些評論/段落。

(2) X 缺少主詞。 -------------∙ 什麼/誰缺主題?

中間有一些評論/段落。

(3) 我的朋友邀請 X 參加聚會。 ---∙ 我的朋友邀請了誰來參加聚會?

中間有一些評論/段落。

(4) -------------------------------------------∙ 我的朋友邀請了誰?

下面的段落中是否也類似(用空格替換減號)?

這一段由於某種原因在某個時刻橫向跳躍-----∙。文本的其餘部分可以跨越其他下一行。

本段希望其跳躍著陸 ---∙ 與上段的跳躍完全相同的絕對水平位置(此處執行得不太完美)。

在跳轉 ∙ 之前到達該位置時如何表現尚未定義,但可以透過跳到下一行並在那裡對齊來定義。

跳躍也可以發生在段落的第二行,看起來更像 ------------------------------ ∙ 這個跳躍。

(我認為)我需要的是一種機制來記住一些水平位置(例如距左邊距30pt)(類似於標籤,既不記住最後生成的數字,也不記住它所在的頁面,但記住它的絕對水平位置) -也許是tikz node? ),然後在文件中稍後恢復它,並使用它在這個絕對位置(距離左邊距 30pt)水平定位某些內容。

我需要的一種特定情況是並行建置但出現在文件的不同部分的語言範例(見上文)。特別是如果它們位於同一頁上,那麼透過這種對齊來顯示它們的歸屬將是很好的視覺語義。在那裡,上面的第 2 點不成立,所以我用了記住tabu最後 MWE 中的表格序言。

該解決方案的一個問題是,比第一個範例的左側部分長的範例的任何其他左側部分都會被破壞。我需要\hspace在第一個單元格的末尾手動添加一些。但這是我可以接受的,因為我很少需要對齊幾個例子。

  This sentence misses X. \hspace*{4em} & What does this sentence miss?\\

第二個問題是,使用表格並不總是一個選項,如上面我的第二個案例所示。有關第二個問題,請參閱 MWE 的末尾,透過手動調整所有\hspace命令解決:

\documentclass{article}
\usepackage{expex}
\usepackage{tabu}

\begin{document}

\ex \begin{tabu}[t]{X[-1]@{\hspace{1em}}X}\savetabu{mypreamble}
  This sentence misses X. & What does this sentence miss?\\
\end{tabu}
\xe

Comments in between.

\ex \begin{tabu}{\usetabu{mypreamble}}
  X misses a subject. & Who/what misses a subject?\\
\end{tabu}
\xe

Another comment.

\ex \begin{tabu}{\usetabu{mypreamble}}
  My friends invited X to the party. & Who did my Friends invite to the party?\\
\end{tabu}
\xe

This paragraph horizontally jumps \hspace*{3em} \textbullet\ at some 
point for some reason. The rest of the text can span other the next lines.

This paragraph wants its jumps to land \hspace*{.5em} \textbullet\ 
exactly at the same absolute horizontal position as the jump from the 
above paragraph (not quite perfectly executed here).

How to behave when the position is reached before jumping \textbullet\ is undefined.

The jump can also happen in the second line of the paragraph, so that it 
looks like \hspace*{16em} \textbullet\ this jump. 

\end{document}

如何以更加自動化的方式實現範例中的案例?

我怎樣才能在段落中實現這一目標?

透過範例和段落對齊項目符號

答案1

以下範例將問題放在\hbox右側。使用最長的問題預先測量盒子的寬度:

\documentclass{article}
\usepackage[
  hmargin=1.5in,
]{geometry}
\usepackage{enumerate}

\newdimen\QuestionLength
\newcommand*{\QuestionFormat}[1]{\textbullet~#1}%
\settowidth{\QuestionLength}{%
  \QuestionFormat{Who did my friends invite to the party?}%
}
\newcommand*{\question}[1]{%
  \leavevmode
  \unskip
  \hspace*{1em plus 1fill}\hbox to \QuestionLength{%
    \QuestionFormat{#1}\hfill
  }%
  \par
}

\begin{document}
\begin{enumerate}[(1)]
\item
  This sentence is missing X.
  \question{What is this sentence missing?}

  Some comment/paragraph(s) in between.

\item
  X is missing a subject.
  \question{What/Who is missing a subject?}

  Some comment/paragraph(s) in between.

\item
  My friends invited X to the party.
  \question{Who did my friends invite to the party?}

  Some comment/paragraph(s) in between.

\item
  \question{Who did my friends invite?}
\end{enumerate}
\end{document}

結果

修復了左側空格的版本

左側最大文字的寬度放入 中\LeftPartLength。然後用目前行寬減去左邊部分的長度和一些分隔空間來計算問題的寬度。如果沒有足夠的空間來容納該問題,則會引發錯誤。

\documentclass{article}
\usepackage[
  hmargin=1.5in,
]{geometry}
\usepackage{enumerate}

\newcommand*{\QuestionFormat}[1]{\textbullet~#1}%
\newdimen\QuestionLength
\newdimen\LeftPartLength
\newdimen\MiddleSep
\setlength{\MiddleSep}{1em}
\settowidth{\QuestionLength}{%
  \QuestionFormat{Who did my friends invite to the party?}%
}
\settowidth{\LeftPartLength}{%
   Some comment/paragraph(s) in between.%
}

\newcommand*{\question}[1]{%
  \leavevmode
  \unskip
  \begingroup
    \dimen0=\dimexpr\linewidth - \LeftPartLength - \MiddleSep\relax
    \ifdim\dimen0<\QuestionLength
      \errmessage{Question is large by %
        \the\dimexpr\QuestionLength-\dimen0\relax.}%
    \fi
    \hspace*{\MiddleSep plus 1fill}%
    \hbox to \dimen0{%
      \QuestionFormat{#1}\hfill
    }%
  \endgroup
  \par
}

\begin{document}
\begin{enumerate}[(1)]
\item
  This sentence is missing X.
  \question{What is this sentence missing?}

  Some comment/paragraph(s) in between.

\item
  X is missing a subject.
  \question{What/Who is missing a subject?}

  Some comment/paragraph(s) in between.

\item
  My friends invited X to the party.
  \question{Who did my friends invite to the party?}

  Some comment/paragraph(s) in between.

\item
  \question{Who did my friends invite?}
\end{enumerate}
\end{document}

結果

答案2

感謝 touhami 的建議,我找到了更通用的解決方案zref-savepos。請參閱包的文件以取得一些說明。一個困難似乎是絕對位置很難處理,而相對位置則可以。最多需要5 合輯把事情做好!

這裡是註解的程式碼:

\documentclass[a4paper,10pt,DIV13]{scrartcl}
\usepackage{expex}
\usepackage{tabu}
\usepackage{ifthen}
\usepackage{calc}
\usepackage{zref-user}
\usepackage{zref-savepos}

\begin{document}

% because the bullets where here only to explicit what I wanted to align
% I didn't include them in the macros

% first the more general solution for paragraphs

\newlength{\tab}% the length of the jumps
\newcommand{\banchor}[1]{\zsaveposx{#1}}% choose the reference point

\newcommand{\balign}[2]{% the 1st argument is the anchorname of the current jump
                        % the 2nd argument is the name of the general anchor chosen
                        % through \banchor
\rule{0pt}{0pt}% to avoid trouble at the beginning of lines
\zsaveposx{#1}\zrefused{#1}% set the reference point from where you want to jump
\setlength{\tab}{\zposx{#2}sp-\zposx{#1}sp}% calculate the length of the jump
\ifthenelse{\lengthtest{\tab<0pt}}% if it's a negative jump,
  {\\\rule{0pt}{0pt}\zsaveposx{#1improbablename}%
    % then begin a new line and set the reference at its beginning
    % with a new anchor name
  \setlength{\tab}{\zposx{#2}sp-\zposx{#1improbablename}sp}% recalculate the jump
  } %
  {}%
\parbox[l]{\tab}{\rule{0pt}{0pt}}% use a \parbox to jump a exact unstrechtable length
% \hspace*{\tab} doesn't work here, because it's strechtable
}

This paragraph horizontally jumps\hspace*{4em}\banchor{B}\textbullet\ at  some point
for some reason. The rest of the text can span other the next lines. 
% this jump is arbitrary, the next ones (previous ones would also work)
% will adapt and align with it

This paragraph wants its jump to land\balign{Ba}{B}\textbullet\ exactly at the same
absolute horizontal position as the jump from the above paragraph (quite perfectly
executed here).

\balign{Bb}{B}\textbullet\ jumping directly to the point is also an option.

How to behave when the position is reached before jumping\balign{Bc}{B}\textbullet\ could
be defined by jumping to the next line.

The jump can also happen The jump can also happen The jump can also happen in the second
line of the paragraph, so that it looks like
\balign{Be}{B}\textbullet\ this jump. 

\bigskip
\hrule

% now to the linguistic examples, following the same principles, 
% but a bit adapted for the more specific needs of the linguistic  examples:
% compile and detect where to put the aligning anchor with \bmark
% use \btab to align the other right parts with it

\newlength{\tabmin}\setlength{\tabmin}{1em}

\newcommand{\bmark}[1]{%
\zsaveposx{#1}\zrefused{#1}\hspace*{\tabmin}}

\newcommand{\btab}[2]{%
\zsaveposx{#1}\zrefused{#1}%
\setlength{\tab}{\tabmin+\zposx{#2}sp-\zposx{#1}sp}%
\hspace*{\tab}}% \hspace* is ok, because wrapped lines are unexpected

\ex This sentence misses X.\btab{Aa}{A}\textbullet\ What does this sentence  miss?
\xe

Comments/explanations/paragraphs in between.

\ex X misses a subject.\btab{Ab}{A}\textbullet\ Who/what misses a subject?
\xe

Another comment.

\ex My friends invited X to the party.\bmark{A}\textbullet\ Who
did my friends invite to the party?
\xe

Another comment.

\ex \btab{Ac}{A}\textbullet\ Who did my friends invite?
\xe

\end{document}

不同段落的對齊文本

編輯

現在我用一個簡單的規則替換了\parbox[l]{\tab}{\rule{0pt}{0pt}}\hspace*{\tab},如果設置為非零高度,它可以幫助可視化精確的跳躍\rule{\tab}{0pt}

改進仍有待完成:我的方法需要使用者找到文件中所需跳轉的盡可能多的不同名稱。也許計數器可以使這部分工作自動化,以便命令\balign\btab只接受一個參數。

在其他地方(在表格中或處理圖形等時)測試這些巨集可能會顯示出一些嚴重的限制。

就目前而言,這個解決方案是我最喜歡的一個。

答案3

第一次近似

\parbox解決方案僅適用於非常短的文字。這是一個更詳細的程序:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{lipsum}

\makeatletter

\def\do#1{\@ifdefinable #1{\newdimen #1}}
% the above is because \newlength allocates a \skip
\do\JumpIndentation
\do\JPprevpardepth

% To allow customization:
\@ifdefinable\EveryJumpingPar{
    \newtoks\EveryJumpingPar \EveryJumpingPar={}
}

\newcommand*\StartJumpingPar{\par
    \JPprevpardepth \prevdepth
    \setbox\z@ \vbox\bgroup
        \color@begingroup % not sure it's really necessary
        \parfillskip \@flushglue
        \prevdepth \JPprevpardepth
        \indent \the\EveryJumpingPar
}
\newcommand*\Jump{%
        \par
        \color@endgroup
    \egroup
    \setbox\tw@ \vbox{%
        \unvcopy\z@
        \setbox\tw@ \lastbox % note that "\indent\par" yields at least one box
        \global \setbox\@ne \hbox{\unhbox\tw@}%
        \global \dimen@i \lastskip % should be -- finger crossed! -- the 
                                  % interline glue above the last box
        \unskip \unpenalty % remove interline glue and widow penalty
        \setbox\tw@ \lastbox % if non-void, assume it is penultimate line
        \global \dimen3 \ifvoid\tw@
            \JPprevpardepth
        \else
            \dp\tw@
        \fi
    }%
    \unvbox\z@
    \ifdim \wd\@ne<\JumpIndentation
        % backspace vertically by one line
        \skip@ \parskip
        \advance \skip@ \ht\@ne
        \advance \skip@ \dp\@ne
        \advance \skip@ \dimen@i
        \vskip -\skip@
        \prevdepth \dimen3
    \else
        \prevdepth \dp\@ne
    \fi
    {\parindent \JumpIndentation \indent}%
    \ignorespaces
}

\makeatother

\setlength{\JumpIndentation}{.57\textwidth} % set as desired



\begin{document}

Let's begin with an ordinart paragraph.

\lipsum[1]

\StartJumpingPar
Now a ``jumping paragraph''.
\lipsum*[1]\Jump\lipsum*[2]

Another ordinary (\emph{i.e.}, ``non-jumping'') paragraph in between, consisting
of at least two lines of text.

\StartJumpingPar
Note that all ``jump'' positions\Jump are vertically aligned, as required.

\StartJumpingPar
If the horizontal position to jump to has already been passed,\Jump the
\verb|\Jump| commands jumps to the next line, as required too.

\StartJumpingPar
Let's try, this time, to get aaaaalmost to\Jump the point!  Now we try again, 
with just one more~``a''.

\StartJumpingPar
Let's try, this time, to get aaaaaalmost to\Jump the point!  Are you satisfied?

\EveryJumpingPar{\textbullet\ }

\StartJumpingPar
Moreover, you can use the token register \verb|\EveryJumpingPar| to customize 
the appearance of\Jump your ``jumping paragraphs''.

That's all, folks!

\end{document}

此程式碼產生的輸出是:

第一次近似的輸出

這應該被視為答案的第一個近似值:在引入可能的增強功能之前,我將等待OP的評論。


第二次近似

這次我們定義一個名為 的環境JumpingParagraphs。該環境必須包含僅有的普通的段落,沒有別的。在此環境所包含的每個段落中,該\Jump指令可用於對由\JumpIndentation剛性長度指定的水平位置進行製表。該\Jump命令可以在同一段落內無限次使用。

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{lipsum}

\makeatletter

\def\do#1{\@ifdefinable #1{\newdimen #1}}
% the above is because \newlength allocates a \skip
\do\JumpIndentation
\do\@JP@normal@indent
\do\@JP@prevpardepth

% To allow customization:
\@ifdefinable\EveryJumpingPar{
    \newtoks\EveryJumpingPar \EveryJumpingPar={}
}

\@ifdefinable\@JP@saved@par{} % just check that the name can be used
\newenvironment*{JumpingParagraphs}{%
    \@JP@normal@indent \parindent
    \let\@JP@saved@par\par
    \def\par{\@JP@par@close\@JP@start@paragraph}%
    \@JP@start@paragraph
}{%
    \@JP@par@close
}
\newcommand*\@JP@start@paragraph{%
    \@JP@par@open\@JP@normal@indent{\the\EveryJumpingPar}%
}
\newcommand*\@JP@par@open[2]{%
    \@JP@prevpardepth \prevdepth
    \setbox\z@ \vbox\bgroup
        \color@begingroup % not sure it's really necessary
        \parfillskip \@flushglue
        \prevdepth \@JP@prevpardepth
        {\parindent #1\indent #2}%
        \ignorespaces
}
\newcommand*\@JP@par@close{%
        \@JP@saved@par
        \global \dimen@i \prevdepth
        \color@endgroup
    \egroup
    \unvcopy\z@
    \prevdepth \dimen@i % for the moment
}
\newcommand*\Jump{%
    \@JP@par@close
    \setbox\z@ \vbox{%
        \unvbox\z@
        \setbox\z@ \lastbox % note that "\indent\par" yields at least one box
        \global \setbox\@ne \hbox{\unhbox\z@}%
        \global \dimen@i \lastskip % should be -- finger crossed! -- the 
                                   % interline glue above the last box
        \unskip \unpenalty % remove interline glue and widow penalty
        \setbox\z@ \lastbox % if non-void, assume it is penultimate line
        \global \dimen3 \ifvoid\z@
            \@JP@prevpardepth
        \else
            \dp\z@
        \fi
    }%
    \ifdim \wd\@ne<\JumpIndentation
        % backspace vertically by one line
        \skip@ \parskip
        \advance \skip@ \ht\@ne
        \advance \skip@ \dp\@ne
        \advance \skip@ \dimen@i
        \vskip -\skip@
        \prevdepth \dimen3
        \dimen@ \ht\@ne
    \else
        \prevdepth \dp\@ne
        \dimen@ \z@
    \fi
    \@JP@par@open\JumpIndentation{\vrule \@width\z@ \@height\dimen@}%
}

\makeatother

\setlength{\JumpIndentation}{.57\textwidth} % set as desired



\begin{document}

Let's begin with an ordinary paragraph.

\lipsum[1]

\begin{JumpingParagraphs}
% No empty lines here!
Now a ``jumping paragraph''.
\lipsum*[1]\Jump\lipsum*[2]
\Jump Regrettably, \verb|Overfull \hbox|'es might occur: this is almost
inevitable, given the fact that a line containing a ``jump'' places a double
constraint on the choice of the breakpoints.

Another ordinary (\emph{i.e.}, ``non-jumping'') paragraph in between, consisting
of at least two lines of text.  Note that it occurs \emph{within} a 
\texttt{JumpingParagraphs} environment.

Note that all ``jump'' positions\Jump are vertically aligned, as required.

If the horizontal position to jump to has already been passed,\Jump the
\verb|\Jump| commands jumps to the next line, as required too.

Let's try, this time, to get aaaaalmost to\Jump the point!  Now we try again, 
with just one more~``a''.

Let's try, this time, to get aaaaaalmost to\Jump the point!  Are you satisfied?

Moreover, you can use the token register \verb|\EveryJumpingPar| to customize 
the appearance of\Jump your ``jumping paragraphs''.  However, it must be set 
\emph{outside} of the \texttt{JumpingParagraphs} environment.

The \verb|\Jump| command can also be used\Jump several times\Jump within a
single paragraph.  And in-line mathematics (say, \( y=\sin(x) \)) may\Jump
occur, too.  As it is quite obvious, you can both jump \emph{to} math\Jump\(
y=\frac{1}{x} \), and \emph{from} math (the last equation is better
written as \( y=1/x \),\Jump isn't it?).  It is also possible to use unusually
high formulas, as in \( \displaystyle
\biggl(\frac{1}{x}+\frac{1}{y}\biggr)\biggl(\frac{1}{x}-\frac{1}{y}\biggr) \),
and, even in case of a\Jump jump, the spacing will be correct!

But alas, \( \displaystyle \frac{x}{y}+\frac{y}{x}=\frac{x^{2}+y^{2}}{xy} \)
\Jump fails miserably: the spacing is correct for the second half of the line,
but not for the first.  You should keep in mind this limitation.  On the other
hand,\Jump \( \displaystyle \frac{x}{y}+\frac{y}{x}=\frac{x^{2}+y^{2}}{xy} \)
works in a more or less acceptable way, as you can see.

\textbf{Main limitation:} a \texttt{JumpingParagraphs} environment cannot
contain \emph{anything} but ordinary paragraphs.
% No empty lines here!
\end{JumpingParagraphs}

This paragraph is outside the \texttt{JumpingParagraphs} environment.  Note 
that line spacing is correct

\bigbreak

\EveryJumpingPar = {\textbullet\ }

We have just set \verb|\EveryJumpingPar| to contain \verb*|\textbullet\ |.  Now 
we start another \texttt{JumpingParagraphs} environment.

\begin{JumpingParagraphs}
    $X$~misses something.
    \Jump What is $X$ missing?

    This sentence misses~$X$.
    \Jump What is missing?

    This sentence $X$ something.
    \Jump What is missing?
\end{JumpingParagraphs}

That's all, folks!

\end{document}

第三(和第四)近似

\par第二個近似值無法正確處理輸入中出現多個標記的情況,因為它可能是由額外的空白行引起的。第三種近似方法透過觸發巨集來修正此缺陷\everypar\@JP@start@paragraph並且還新增了\EveryJump令牌暫存器:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{color}

\definecolor{subdued}{gray}{.75}

\makeatletter

\def\do#1{\@ifdefinable #1{\newdimen #1}}
% the above is because \newlength allocates a \skip
\do\JumpIndentation
\do\@JP@normal@indent
\do\@JP@prevpardepth

% To allow customization:
\def\do#1{\@ifdefinable #1{\newtoks #1#1{}}}
\do\EveryJumpingPar
\do\EveryJump

\@ifdefinable\@JP@saved@par{} % just check that the name can be used
\@ifdefinable\@JP@next{}
\newenvironment*{JumpingParagraphs}{%
    \everypar{\@JP@start@paragraph}%
}{%
    \par
}
\newcommand*\@JP@start@paragraph{%
    \@JP@normal@indent \parindent
    \let\@JP@saved@par\par
    \setbox\z@ \lastbox % get indentation box
    \@@par % return to vertical mode with an empty paragraph
    \ifvoid\z@
        \let \@JP@next \noindent
    \else
        \let \@JP@next \indent
    \fi
    \@JP@par@open\@JP@next\@JP@normal@indent{\the\EveryJumpingPar}%
}
\newcommand*\@JP@par@open[3]{%
    % #1 <- either "\indent" or "\noindent"
    % #2 <- indentation amount
    % #3 <- tokens to insert at the beginning of the paragraph
    \@JP@prevpardepth \prevdepth
    \setbox\z@ \vbox\bgroup
        \color@begingroup % not sure it's really necessary
        \parfillskip \@flushglue
        \everypar{}%
        \let\par\@JP@par@close
        \prevdepth \@JP@prevpardepth
        {\parindent #2#1#3}%
        \ignorespaces
}
\newcommand*\@JP@par@close{%
        \@JP@saved@par
        \global \dimen@i \prevdepth
        \color@endgroup
    \egroup
    \unvcopy\z@
    \prevdepth \dimen@i % for the moment
}
\newcommand*\Jump{%
    \@JP@par@close
    \setbox\z@ \vbox{%
        \unvbox\z@
        \setbox\z@ \lastbox % note that "\indent\par" yields at least one box
        \global \setbox\@ne \hbox{\unhbox\z@}%
        \global \skip\@ne \lastskip % should be -- finger crossed! -- the 
                                    % interline glue above the last box
        \unskip \unpenalty % remove interline glue and widow penalty
        \setbox\z@ \lastbox % if non-void, assume it is penultimate line
        \global \dimen@i \ifvoid\z@
            \@JP@prevpardepth
        \else
            \dp\z@
        \fi
    }%
    \ifdim \wd\@ne<\JumpIndentation
        % backspace vertically by one line
        % Note: no "\parskip" glue is added in internal vertical mode when the
        %       current list is empty, so we don't need to compensate for it!
        \skip@ \skip\@ne
        \advance \skip@ \ht\@ne
        \advance \skip@ \dp\@ne
        \vskip -\skip@
        \prevdepth \dimen@i
        \dimen@   \ht\@ne
        \dimen@ii \dp\@ne
    \else
        \prevdepth \dp\@ne
        \dimen@   \z@
        \dimen@ii \z@
    \fi
    \@JP@par@open\indent\JumpIndentation{%
        % It was trivial to fix this one!
        \vrule \@width\z@ \@height\dimen@ \@depth\dimen@ii \relax
        % Now "\relax" is no longer necessary, actually.
        \the\EveryJump
    }%
}

\makeatother

\setlength{\JumpIndentation}{.57\textwidth} % set as desired



\begin{document}

Let's begin with an ordinary paragraph.

\lipsum[1]

\begin{JumpingParagraphs}

% Empty lines are now allowed here.

Now a ``jumping paragraph''.
\lipsum*[1]\Jump\lipsum*[2]
\Jump Regrettably,\hfil\verb|Overfull \hbox|'es might occur: this is almost
inevitable, given the fact that a line containing a ``jump'' places a double
constraint on the choice of the breakpoints.

% Multiple blank lines in the input are now handled correctly:


Another ordinary (\emph{i.e.}, ``non-jumping'') paragraph in between, consisting
of at least two lines of text.  Note that it occurs \emph{within} a 
\texttt{JumpingParagraphs} environment.

Note that all ``jump'' positions\Jump are vertically aligned, as required.

If the horizontal position to jump to has already been passed,\Jump the
\verb|\Jump| commands jumps to the next line, as required too.

Let's try, this time, to get aaaaalmost to\Jump the point!  Now we try again, 
with just one more~``a''.

Let's try, this time, to get aaaaaalmost to\Jump the point!  Are you satisfied?

\EveryJumpingPar = {\textbullet\ }

Moreover, you can use the token register \verb|\EveryJumpingPar| to customize 
the appearance of\Jump your ``jumping paragraphs''.

\EveryJump = {\textasteriskcentered\ }

In the same way, the \verb|\EveryJump| tokens\Jump are inserted each time a
\verb|\Jump| command\Jump is executed, as it is exemplified by this same\Jump
paragraph.

These token registers can now also be set inside the \texttt{JumpingParagraphs}
environment itself.

\EveryJumpingPar = {}
\EveryJump = {}

The \verb|\Jump| command can also be used\Jump several times\Jump within a
single paragraph.  And in-line mathematics (say, \( y=\sin(x) \)) may\Jump
occur, too.  As it is quite obvious, you can both jump \emph{to} math\Jump\(
y=\frac{1}{x} \), and \emph{from} math (the last equation is better
written as \( y=1/x \),\Jump isn't it?).  It is also possible to use unusually
high formulas, as in \( \displaystyle
\biggl(\frac{1}{x}+\frac{1}{y}\biggr)\biggl(\frac{1}{x}-\frac{1}{y}\biggr) \),
and, even in case of a\Jump jump, the spacing will be correct!

And now, also \( \displaystyle \frac{x}{y}+\frac{y}{x}=\frac{x^{2}+y^{2}}{xy} \)
\rlap{\color{subdued}sminnief}\Jump functions with absolute perfection: line
spacing is correct both for the first half of the line and for the second one.
On the other hand,\Jump \( \displaystyle
\frac{x}{y}+\frac{y}{x}=\frac{x^{2}+y^{2}}{xy} \) works in a less satisfactory
way, as you can see.  You should keep in mind this limitation.

\textbf{Main limitation:} a \texttt{JumpingParagraphs} environment cannot
contain \emph{anything} but ordinary paragraphs.

\noindent Note that \verb|\noindent| commands\Jump \emph{are} honored: indeed,
this has now been corrected (in an update).

\begingroup

\setlength{\parindent}{4em}

Also, \verb|\parindent| may now vary\Jump from one paragraph\Jump to another:
I~had completely overlooked this in the previous versions!

Another paragraph with the same\Jump different indentation.

\endgroup

Back to previous indentation,\Jump with a jump.

One last paragraph without jumps.

% Empty lines are now allowed here.

\end{JumpingParagraphs}

This paragraph is outside the \texttt{JumpingParagraphs} environment.  Note 
that line spacing is correct.

\bigbreak

\newcounter{sentence}
\renewcommand*{\thesentence}{{\normalfont (\textit{\alph{sentence}})}}
\EveryJumpingPar = {\refstepcounter{sentence}\llap{\thesentence\ }}
\EveryJump = {\textbullet\ }

We have just set \verb|\EveryJumpingPar| to contain a numbered label, which is
automatically stepped, and \verb|\EveryJump| to contain \verb*|\textbullet\ |.
Now we start another \texttt{JumpingParagraphs} environment.

\begin{JumpingParagraphs}
    \setlength{\parskip}{\medskipamount}

    $X$~misses something.
    \Jump What is $X$ missing?

    This sentence misses~$X$.
    \Jump What is missing?

    This sentence $X$ something.
    \Jump What is missing?

    Now, get close to the jump destination...
    \Jump to be sure that the baselines are lined up properly.
\end{JumpingParagraphs}

That's all, folks!

\end{document}

這次我也將顯示輸出:

第三/四近似的輸出

採用的解決方案zref-savepos確實比這更靈活;然而,我認為展示如何完全使用良好的“plain-TeX-style”方法來實現目標可能會很有趣:不依賴\pdfsavepos同時運行的 和 相關原語\shipout,不需要兩個-通過編譯,只是玩弄盒子和膠水。


我必須坦白承認,這個問題抓住我了!我反覆完善我的答案,我可能最終會發布一個完整的包...

答案4

對於段落的情況,我找到了一個使用 a\parbox跳過其文字的解決方案。我不知道這是否\hbox是一個更好的主意。這解決了跳轉發生在段落第一行的情況。

\newlength{\jumplength}
\setlength{\jumplength}{20em} % adjust manually
\newcommand{\jumping}[1]{\parbox[l]{\jumplength}{#1}}

\jumping{This paragraph horizontally jumps}\textbullet\ at some point
for some reason. The rest of the text can span other the next lines.

\jumping{This paragraph wants its jump to land}\textbullet\ exactly at  
the same absolute horizontal position as the jump from the above paragraph.

\jumping{~}\textbullet\ jumping directly to the point is also an option.

不同段落中的點對齊

為了準確起見,Heiko 的第二個答案應該是

\settowidth{\LeftPartLength}{%
My friends invited X to the party.%
}

完全符合我的需求,這給了略有不同的結果:

在此輸入影像描述

相關內容