Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reference to page numbers of an element tag #242

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chihyang
Copy link

@chihyang chihyang commented Jun 7, 2020

This is a pull request working in progress.

For docs such as pdf, page number reference is sometimes very useful. To support page reference, a new kind of tag is added to scribble/base. Besides, a new command PageRef is added to scribble.tex. Its argument is a page number. By default, it shows 'page' before the page number. Users can redefine this command to get different outputs.

For docs such as pdf, page number reference is sometimes very useful. To support
page reference, a new kind of tag is added to scribble/base. Besides, a new
command 'PageRef' is added to scribble.tex. Its argument is a page number. By
default, it shows 'page' before the page number. Users can redefine this command
to get different outputs.
@chihyang
Copy link
Author

chihyang commented Jun 7, 2020

@mflatt @samth This is a pull request working in progress. I am not sure if it is suitable for merging into the main scribble repo. So I put it here for discussion.

Support for page number reference in PDF is very useful. Support for page number reference in HTML or other formats seems less meaningful, because most of time there is no fix-sized paper in such documents (maybe this is why pageref is not added to scribble code?). In these formats, maybe it's better to render pageref as a hyperlink with configurable text like "here".

This is also a problem about how to use tags more conveniently: how can I use something like LaTeX \ref in scribble, and make it work in all the supported documents? I read the documents several times, but I didn't find an easy way. Now enconde-tag (in different names) is implemented in different renders, so this seems a little hard. But if there is a way to use the real content of a tag in the document directly, things like pageref can be avoided.

For example, once we can use the "real" content of a tag, I can define the following style:

\newcommand{\PageRef}[1]{page~\pageref{#1}}

then in the style file:

(define PageRef
  (make-style "PageRef" (list (make-tex-addition "pageref.tex"))))

then in the scribble file:

;;; tag here
(elemtag "a-tag")

;;; use the tag somewhere else
(elem #:style PageRef (encode-tag "a-tag"))

Because encode-tag extracts content of a tag, it is also possible to define different styles for different formats.

@chihyang chihyang marked this pull request as ready for review November 16, 2020 18:07
@chihyang chihyang changed the title [WIP] Support reference to page numbers of an element tag Support reference to page numbers of an element tag Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant