
ドキュメント内の任意の 2 つ以上の場所を水平に揃える方法を見つけたいのですが (ただし、おそらく同じページ上か、互いにあまり離れていない場所)。これは表形式の 2 番目の列に少し似ていますが、次のようになります。
- 「行」は任意の数で区切ることができます。(表は行間で分割できます。)
- 配置するポイントは、通常の段落の中央に表示されても段落の残りの部分がこの配置の影響を受けないため、表の行またはセルに属しているとは必ずしも見なされません。
次の例ですべての箇条書きを揃えるにはどうすればよいですか (マイナス記号を空白に置き換えます)?
(1) この文にはXが欠けています。 ---------∙ この文に欠けているものは何ですか?
間にいくつかのコメント/段落があります。
(2) X には主語が欠けています。 -------------∙ 主語が欠けているのは何ですか/誰ですか?
間にいくつかのコメント/段落があります。
(3) 友達がXをパーティーに招待しました。 ---∙ 友達は誰をパーティーに招待しましたか?
間にいくつかのコメント/段落があります。
(4) -------------------------------∙ 友達は誰を招待したのでしょうか?
次の段落でも同様ですか (マイナス記号を空白に置き換えます)?
この段落は、何らかの理由で、ある時点で水平方向に-------∙ジャンプします。テキストの残りの部分は、次の行にまたがっている可能性があります。
この段落では、ジャンプが ---∙ 上の段落からのジャンプとまったく同じ絶対水平位置に着地することを望んでいます (ここでは完全には実行されていません)。
ジャンプする前の位置に到達したときの動作は定義されていませんが、次の行にジャンプしてそこに配置することで定義できます。
ジャンプは段落の 2 行目でも発生する可能性があり、その場合は -------------------------------∙ このジャンプのように見えます。
私が必要としているのは(私が思うに)ある水平位置(たとえば左余白から 30pt)を記憶するメカニズム(最後に生成された番号も、そのページも記憶せず、絶対的な水平位置(おそらく ?)だけを記憶するラベルのようなもの)でtikz node
、それを後で文書内で復元し、この絶対位置(左余白から 30pt)に何かを水平に配置するために使用します。
これが必要となる特定の状況の 1 つは、並列に構築されているが、ドキュメントの異なる部分に表示される言語例の場合です (上記を参照)。特に、同じページにある場合は、この配置によってそれらが一緒に属していることを示すことが視覚的な意味論として適切です。この場合、上記のポイント 2 は当てはまらないため、tabu
最後に MWE 内の表形式の序文を記憶することを使用しました。
このソリューションの問題点は、最初の例の左側部分よりも長い例の左側部分がさらに長くなると、その部分が壊れてしまうことです。\hspace
最初のセルの末尾に手動で追加する必要があります。ただし、数個以上の例を揃える必要はほとんどないので、これは問題ありません。
This sentence misses X. \hspace*{4em} & What does this sentence miss?\\
2 番目の問題は、上記の 2 番目のケースで示したように、表形式の使用が常にオプションであるとは限らないことです。2 番目の問題については、すべての\hspace
コマンドを手動で調整することで解決した MWE の最後を参照してください。
\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
次の例では、右側のa に質問を配置します。ボックスの幅は、最も長い質問を使用して事前に測定されます。
\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
。説明についてはパッケージのドキュメントを参照してください。1つの難点は、絶対位置は扱いにくいのに相対位置は問題ないということです。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}
。
改善はまだ保留中です。私のアプローチでは、ユーザーはドキュメント内で必要なジャンプと同じ数の異なる名前を見つける必要があります。おそらくカウンターでこの部分の作業を自動化して、コマンドが 1 つの引数だけを取るようにできるでしょ\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 のコメントを待ちます。
2番目の近似値
今回は という環境を定義します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}
3番目(および4番目)の近似値
2 番目の近似では、入力に複数のトークンが出現するケースを正しく処理できませんでした。これは、余分な空白行が原因である可能性があるためです。3 番目の近似では、マクロをトリガーする\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
確かにこれよりも柔軟です。しかし、 および\pdfsavepos
関連プリミティブを -time で操作する必要\shipout
もなく、2 パス コンパイルも必要なく、ボックスとグルーを操作するだけで、古き良き「プレーン TeX スタイル」の方法で目標を完全に達成できる方法を示すことは興味深いかもしれません。
私ははっきり認めなければならない、この質問もっている捕まりました!私は何度も回答を改良しており、最終的には完全なパッケージを投稿することになるでしょう...
答え4
段落の場合、\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.
正確さを期すために、ヘイコの2番目の答えは次のようになるべきである。
\settowidth{\LeftPartLength}{%
My friends invited X to the party.%
}
私のニーズに正確に対応するため、少し異なる結果が得られます。