
내 문서의 두 개 이상의 임의 위치를 수평으로 정렬하는 방법을 찾고 싶습니다(그러나 아마도 같은 페이지에 있거나 서로 너무 멀지 않을 것입니다). 표 형식의 두 번째 열과 약간 비슷하지만 다음과 같습니다.
- "행"은 얼마든지 분리될 수 있습니다. (표 형식은 행 간에 분할될 수 있습니다.)
- 정렬할 점이 항상 표 형식의 행이나 셀에 속하는 것으로 볼 수는 없습니다. 왜냐하면 이 정렬의 영향을 받지 않고 단락의 나머지 부분이 일반 단락의 중간에 나타날 수 있기 때문입니다.
다음 예에서 모든 글머리 기호를 정렬하는 방법은 무엇입니까(마이너스를 공백으로 대체)?
(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}
편집하다
이제 0이 아닌 높이로 설정된 경우 정확한 점프를 시각화하는 데 도움이 될 수 있는 간단한 규칙으로 \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
실제로 이보다 더 유연합니다. 그러나 나는 좋은 "일반 TeX 스타일" 방법을 사용하여 목표를 완전히 달성할 수 있는 방법을 보여주는 것이 흥미로울 수 있다고 생각합니다. -time \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.%
}
내 요구 사항에 정확하게 부합하므로 약간 다른 결과가 나타납니다.