optex 中的顺序(单行)尾注

optex 中的顺序(单行)尾注

受到这个问题的启发这里,我想这样设置 entnotes 的样式 (plain/optex):

1.第一个尾注,尾注编号与正文大小相同,不是上标,粗体,后面有一个点。2.第二个 entnote 在同一行,以节省空间。3.同一行上的第三个 ntnote

以下是我目前为止做过(还未做过)的事情:

\ptlang
\fontfam[Heros]
\typosize[10/14]
\verbchar`                     % in-text verbatim by `...`
\everyintt={\Red\bf}              % in-text verbatim Red
%\famvardef\tt{\Heros\setff{-liga;-tlig}}
%\everytt={\hisyntax{TEX}}
%\hyperlinks

\famvardef\tt{\Heros}


%\parskip=0pt plus 4pt minus 4pt

%%%%%%%%%%%%%footnote style below:%%%%%%%%%%%%%
\def\fnmark#1{\leavevmode\raise.7ex\hbox{\setfontsize{mag.6}\lnum\currvar #1}} %Olsak's definition 
\def\_printfnotemark{\fnmark{\_fnotenum}}


%%%%%%%%%%%%%%%


%\input endnote


% Use \endnote{1}{text}. At the end of your document, type
% \producenotes to actually flush all end notes to be printed.
%
% macros for making endnotes instead of footnotes
% We make @ signs act like letters, temporarily, to avoid conflict
% between user names and internal control sequences of plain format.
\catcode`@=11
\newbox\endnotebox
\def\setendnotefont#1{\gdef\endnotefont{#1}}
\setendnotefont{\rm}
\def\endnote#1{\let\@sf\empty
  \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  #1\@sf\vendnote{{#1}}}
\def\vendnote#1{\global\setbox\endnotebox=
   \vbox{\parindent=0pt\hangindent=0.5em\hangafter=1 
\endnotefont\unvbox\endnotebox\bgroup
   \indent\llap#1\ignorespaces\futurelet\next\aftergroup\no@te\relax}}
\def\no@te{\ifcat\bgroup\noexpand\next \let\next\n@@te
  \else\let\next\n@t\fi \next}
\def\n@@te{\bgroup\aftergroup\@endnote\let\next}
\def\n@t#1{#1\@endnote}
\def\@endnote{\strut\egroup}
%
\newcount\enotecounter
\def\resetenotecount{\global\enotecounter=0 } \resetenotecount
\def\setenotecount#1{\global\enotecounter=#1 }
%
\def\setendnoteflagfont#1{\gdef\endnoteflagfont{#1}}
\setendnoteflagfont{\sevenrm}
\def\enote{\unskip
  \global\advance \enotecounter by 1  % First bump the counter.
  % Now convert the current value of the counter into a superscripted numeral
  %\endnote{{$^{\hbox{\endnoteflagfont\the\enotecounter}}$}}
  \endnote{\fnmark{\the\enotecounter} } % aqui mudamos para nossa definição
  }
%
\def\producenotes{\ifvoid\endnotebox\else\medskip\unvbox\endnotebox\par\fi}
\catcode`@=12 % at signs are no longer letters


\chap Um capítulo


\begmulti 2

Hello world! This is to have an endnote.\enote{Automatic note 1} \enote{Automatic note 2, which should be on the same line, and {\bf [2] } text...} 

\nonum \sec Notas para o capítulo 1

\producenotes
\endmulti


\bye

答案1

我确信有一种纯粹基于宏的方法可以做到这一点,但是为了好玩,这里有一个基于 Lua 的解决方案:

% Endnote code
\_namespace{endnote}
% Initialize variables
\_newcount\.number
\_newcount\.page
\_newbox\.contents
\_directlua{
    endnotes = {}
    unpaged_endnotes = {}
}

% Format the endnote marks
\_newpublic\_def\endnotecmd#1{#1}

% Define the endnote command
\_newpublic\_def\endnote#1{%
    \_setbox\.contents=\_hbox{#1}%
    \_global\_advance\.number by 1%
    \endnotecmd{\_the\.number}%
    \_directlua{
        local number = tex.count.\_csstring\.number;
        local box = tex.box.\_csstring\.contents;
        unpaged_endnotes[number] = true
        endnotes[number] = { node.copy_list(box) }
    }%
    \_latelua{
        for note in pairs(unpaged_endnotes) do
            table.insert(endnotes[note], tex.count[0])
        end
        unpaged_endnotes = {}
    }%
}

% Lua-based helpers
\_directlua{
    optex.define_lua_command("\_csstring\.getnote", function()
        local number = token.scan_int()
        local note = endnotes[number]
        tex.box.\_csstring\.contents = note[1]
        tex.count.\_csstring\.page = note[2] or tex.count[0]
        tex.count.\_csstring\.number = number
    end)

    local integer_token = token.command_id("char_given")
    optex.define_lua_command("\_csstring\.gettotal", function()
        token.put_next(token.create(\string#endnotes, integer_token))
    end)
}

% Content before the endnotes
\_newpublic\_def\premakeendnotes{}
\_newpublic\_def\postmakeendnotes{}

% Get the endnotes
\_newpublic\_def\makeendnotes{%
    \premakeendnotes%
    \_fornum 1..\.gettotal \_do {\.makenote{##1}}%
    \_global\.number=0%
    \directlua{
        endnotes = {}
        unpaged_endnotes = {}
    }%
    \postmakeendnotes%
}

\_def\.makenote#1{%
    \.getnote #1
    \makeendnote{\_the\.number}{\_the\.page}{\.contents}%
}

% Format the endnote contents
% #1 = endnote number
% #2 = page number
% #3 = endnote contents
\_newpublic\_def\makeendnote#1#2#3{#2}
\_endnamespace

% User code
\fontfam[lm]

%% Style 1
\def\endnotecmd#1{\unskip$^{#1}$}
\def\premakeendnotes{%
    \bigskip%
    \_begingroup%
    \raggedright%
}
\def\makeendnote#1#2#3{%
    \noindent%
    {\bf #1.~}%
    \_unhbox#3%
    \quad\_penalty-1000%
}
\def\postmakeendnotes{%
    \_par%
    \_endgroup%
    \vfill\eject%
}

%% Style 2
% \def\endnotecmd#1{\unskip\raise.5ex\hbox{\typosize[6/]\it #1}}
% \def\premakeendnotes{%
%     \vfill\eject
%     \nonum\_insec{Endnotes}
%     \parindent=0pt
% }
% \def\makeendnote#1#2#3{%
%     {\bf #1:} \_unhbox#3\ (page #2)\par%
% }

\chap One

One\endnote{First endnote.} two\endnote{Second endnote.}.
% \vfill\eject
Three\endnote{Third endnote.} four\endnote{Fourth endnote.}
five\endnote{Fifth endnote.} six\endnote{Sixth endnote.}.

\makeendnotes

\chap Two

One\endnote{First endnote.} two\endnote{Second endnote.}.
% \vfill\eject
Three\endnote{Third endnote.} four\endnote{Fourth endnote.}.

\makeendnotes

\bye

样式 1: 在此处输入图片描述

样式 2: 在此处输入图片描述

相关内容