페이지가 완료되면 매크로 값을 저장합니다.

페이지가 완료되면 매크로 값을 저장합니다.

이전 질문에 대한 답변을 얻지 못한 후 MWE를 실제 문제라고 생각되는 부분으로 정리했습니다. 정보를 저장하는 매크로가 있습니다 \recent(-링크에 필요함 hyperref). 이 매크로는 특정 명령( \newone)이 실행될 때 정기적으로 업데이트(즉, 덮어쓰기)됩니다.

\recent참조 목적으로 페이지 끝이나 새 페이지 시작 부분에 이 매크로(예: )의 값을 다른 매크로( )에 저장하고 싶습니다 ( 모든 페이지에 -backlink를 \previous추가해야 함 ). hyperref나는 일반적인 용의자들( everypage, evershi, atbegshi; bophook을 좋아하지 않는 것 같습니다 hyperref)에 간섭했지만 어떻게든 \previous-macro가 곧 또는 잘못된 시간에 업데이트됩니다.

문제를 설명하려면 이 MWE를 고려하십시오. 일반 매크로를 사용하여 " newtoks" 후에 " " 로 전환했지만 renewcommand{\previous}{\recent}성공하지 못했지만 문제에 도움이 되지 않았습니다.

아이디어는 \previous헤드라인에 실제 " "를 포함하는 것입니다. 그러나 MWE가 보여주듯이 이는 사실이 아니다. 아마도 그것에 대한 매우 간단한 해결책이 있을 것이고 아마도 출하 메커니즘과 관련이 있을 것입니다. 그러나 나는 그것을 보기에는 너무 눈이 멀고 경험이 없습니다.

모든 도움에 감사드립니다.

[이전 질문: https://tex.stackexchange.com/questions/539473/control-the-referencing-of-labels-in-headlines-hyperref-komascript-or-how-a ]

\documentclass[%
12pt,% 
twoside=false,%
cleardoublepage=empty,%
open=right,% 
parskip=half*,% 
headings=normal,% 
numbers=noenddot,% 
chapterprefix=true,% 
%draft % 
]{scrbook}

\usepackage[headsepline]{scrlayer-scrpage} \pagestyle{scrheadings}
\clearscrheadfoot 

\newcommand{\JumpBackHeadline}{\pagemark -- \the\previous}

\ohead{\JumpBackHeadline}
  
\usepackage{everypage}
\usepackage{blindtext}

\newtoks{\recent}
\newtoks{\previous}
\global\recent={dummyrecent}
\global\previous={dummyprevious}


\AddEverypageHook{%
  previous before EverypageHookoperation: \the\previous\\%
  \global\previous={\the\recent}%
  previous after EverypageHookoperation: \the\previous
}

\newcommand{\newone}[1]{%
  my argument is: #1\\
  previous is: \the\previous\\
  recent was:  \the\recent\\
  \global\recent={#1}
  recent is: \the\recent
}


\begin{document}
Starting:\\
previous is: \the\previous\\
recent is:  \the\recent

\newone{number1}

\blindtext[5]

\newone{number2}

And now lots of text:\\

\blindtext[10]

\newone{number3}
\end{document}

수정: 혼란을 드려 죄송합니다. 다음 MWE가 내가 원하는 것을 더 잘 보여주기를 바랍니다. 내 관심사는 페이지 번호가 아니라 링크 레이블입니다. MWE의 "질문 1에 대한 답변"에서 개념을 설명하려고 합니다. 아마도 전체 접근 방식이 엉망일 것입니다. 누군가 더 좋은 아이디어가 있다면 주저하지 말고 댓글을 달아주세요.

\documentclass[
  12pt,
  twoside=false,
  cleardoublepage=empty,
  open=right,
  parskip=half*,
  headings=normal,
  numbers=noenddot,
  chapterprefix=true,
  %draft,
]{scrartcl}

\usepackage{everypage}
\usepackage{blindtext}
\usepackage{marginnote}
\usepackage{ifthen,ragged2e}
\usepackage{hyperref}
%%% The Headline %%%%
\usepackage[headsepline]{scrlayer-scrpage} \pagestyle{scrheadings}
\clearscrheadfoot

\newcommand{\JumpBackHeadline}{% define the headline, depening on JumpBackOn
  \ifthenelse{\boolean{JumpBackOn}}%
  {\pagemark -- Quick link to
    \hyperref[\previous]{\previous}}% Hyperlink only, if jumpback is on
  {\pagemark}% %otherwise, i.e. in the questions section, just the
             % pagemark
}

\ohead{\JumpBackHeadline}

%% The jump commands to set the hyperlinks

\newboolean{JumpBackOn}  % Switch on for jumpback hyperlinks
\setboolean{JumpBackOn}{false} % but not in the first (questions) section


\newcommand{\jumpdown}[1]{\marginnote{\RaggedRight\tiny{\hyperref[#1]{Down
        to
        #1}}}} % Hyperlink to jump from the question in the questions
               % section to the label at the start of the answer in
               % the answer section; #1 is this label

\newcommand{\jumpback}[1]{% Jump from the answer to the label at the start of the corresponding question in the questions section; #1 is this label.
  \gdef\recent{#1}% Remember this label, it is the label to the question that is currently being discussed.
  \marginnote{\RaggedRight\tiny{\hyperref[#1]{Up to
        #1}}} % place the hyperlink in the margin
}


%%%% When a page is finished and shipped out: remember the label in
%%%% \recent *at this time* by storing it in \previous

\AddEverypageHook{%
  % globally make \previous the same as the current \recent
  \global\let\previous=\recent
}

\begin{document}

\section{Questions for students (sometimes very
  long)}\setboolean{JumpBackOn}{false}
   
\begin{enumerate}
\item[1.] Question 1 \label{q:1}\jumpdown{a:1}

  \blindtext

\item[2.] Question 2 \label{q:2}\jumpdown{a:2}

  \blindtext

\item[3.] Question 3 \label{q:3}\jumpdown{a:3}

  \blindtext

\item[4.] Question 4 \label{q:4}\jumpdown{a:4}

  \blindtext
  
\end{enumerate}

\clearpage

\section{Answers, sometimes very
  long}\setboolean{JumpBackOn}{true} % From now on, jumpback link in headline


\subsection{Answer to question 1}\label{a:1}\jumpback{q:1}

This is the answer text to question 1. In the margin, a label links
back to question 1; this link is correct. However, as this answer text
extends over a few pages, students should have a quick link in the
headline of each page to jump back to question 1 until answer 1 is
finished. The link should be at the same position in the top or maybe
bottom region of every page; it does not have to be the header, if
this causes trouble.

The link in the headline (or somewhere else) should point to the label
of the question that is (still) discussed \emph{at the beginning of
  each page}. In our case, that is question 1 for page 3, 4 and 5.
However, on page 5 there is a link to question 2, not 1. Similarly, on
page 6 there is a link to question 3, not 2, although this question
starts at the top of the next page.

Again, at page 7, the link points to question 4, even though this
question starts at the top of the next page. The link on page 8 is
also wrong, although it appears right: If the previous-linklabel is
fixed at the end of page 7 and this label would then (correctly) point
to question 3, it should point to question 3 at the top of page 8 as
well, although this is not what I want: It is a design failure on my
part, but I have no better idea at the moment. If anyone knows how to
approach the whole thing in a better way, I would be grateful.



\blindtext[9]

\subsection{Answer to question 2}\label{a:2}\jumpback{q:2}

\blindtext[7]


\subsection{Answer to question 3}\label{a:3}\jumpback{q:3}



\blindtext[4]

Some space to fill the page:


\vfill
\subsection{Answer to question 4}\label{a:4}\jumpback{q:4}

\blindtext


\end{document}

답변1

\global\previous={\the\recent}~ 할 것이다~ 아니다의 현재 콘텐츠를 전달합니다 \recent. 당신은해야합니다

\global\previous=\expandafter{\the\recent}

하지만 사용하는 것이 더 좋다고 생각합니다 \global\let.

\documentclass[
  12pt,
  twoside=false,
  cleardoublepage=empty,
  open=right,
  parskip=half*,
  headings=normal,
  numbers=noenddot,
  chapterprefix=true,
  %draft,
]{scrbook}

\usepackage[headsepline]{scrlayer-scrpage} \pagestyle{scrheadings}
\clearscrheadfoot 

\newcommand{\JumpBackHeadline}{\pagemark -- \previous}

\ohead{\JumpBackHeadline}

\usepackage{everypage}
\usepackage{blindtext}

\def\recent{dummyrecent}
\def\previous{dummyprevious}


\AddEverypageHook{%
  previous before EverypageHookoperation: \previous\\%
  % globally make \previous the same as the current \recent
  \global\let\previous=\recent
  previous after EverypageHookoperation: \previous
}

\newcommand{\newone}[1]{%
  my argument is: #1\\
  previous is: \previous\\
  recent was:  \recent\\
  \gdef\recent{#1}%
  recent is: \recent
}


\begin{document}
Starting:\\
previous is: \previous\\
recent is:  \recent

\newone{number1}

\blindtext[5]

\newone{number2}

And now lots of text:

\blindtext[10]

\newone{number3}
\end{document}

관련 정보