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

Add anchor to DndMonster environment #337

Open
timvdalen opened this issue Jan 16, 2022 · 8 comments
Open

Add anchor to DndMonster environment #337

timvdalen opened this issue Jan 16, 2022 · 8 comments

Comments

@timvdalen
Copy link

Because the DndMonster environment doesn't place an anchor, it's currently not possible to refer to it.
A possible workaround is by adding a \phantomsection to the monster.

Properly anchoring the DndMonster environment would allow stuff like \nameref{} to work as well.

@BrianCriswell
Copy link
Member

I just handle the links myself. This is how my statblocks all start:

\begin{WbsStatBlock}{\pagetarget{npc:couatl}{Couatl}}
  \DndMonsterType{Medium celestial, lawful good}

WbsStatBlock encapsulates DndMonsterNoBg with custom styling. \pagetarget is a function I added that sets a reference, and a corresponding \pagelink links to the reference, emitting a hyperlink in PDFs and a "p. ##" in print on demand.

We have generally avoided auto-linking because of the chance of characters in the name which would not be valid in the anchor. Setting the reference myself allows me to avoid illegal characters and simplify the link. If illegal characters are automatically stripped, there is a small chance of a collision in the references of two similarly named creatures. Adding an argument which forces the reference to a value would avoid the collisions, and it could be set when needed.

Another hurdle is that the user might not know what illegal characters were automatically stripped, and what the resulting reference is.

Do you have some suggestions for how to go about this?

@timvdalen
Copy link
Author

timvdalen commented Jan 18, 2022

Sorry, I wasn't suggesting autolinking (and I agree with your reasoning about why it doesn't make sense).
Perhaps the DndMonster environment could take an optional argument label?
If that's set, we could \phantomsection\label{#1}.
Then you'd be able to:

\begin{DndMonster}[label=monster:wolf]
...
\end{DndMonster}

@BrianCriswell
Copy link
Member

So this is what I had in my class for creating cross-references (with the print on demand part stripped out).

\NewDocumentCommand {\pagetarget} { m m }
  {
    \phantomsection
    \label {#1}
    \hypertarget {#1} {#2}
  }

\NewDocumentCommand {\pagelink} { m m }
  {
    \hyperlink {#1} {#2}
  }

What would you propose for how DndMonster adds in the label, and what should a function to reference the label look like?

@timvdalen
Copy link
Author

I didn't know about hypertarget, I just reference them 'by hand' since there's usually some pluralization going on as well.
For an initially worthwhile solution, I think adding \phantomsection\label{#1} to the environment (if #1 is defined) would work well enough.

Basically, as a user, I was expecting DndMonster to define a section so I could add a label to it.
Perhaps just adding \phantomsection would be enough, but that might mess with people's expectations of sections.

PS. Interesting that you mention print on demand, I've actually also been working on that.
I now have a class that works for Amazon KDP (including a variant of the page decorations with bleed that I'll push to my fork), would you be interested in a PR that adds a print option to the class to enable bleed and margins?

@BrianCriswell
Copy link
Member

Hmm, I would need to reexamine sections to get a clearer picture on what is needed.

As for PoD, I think it would need to satisfy DTRPG. Amazon's PoD service is pretty lenient and seems to accept anything that DTRPG accepts, but not the other way around.

@timvdalen
Copy link
Author

RE: PoD, for sure. I've been able to satisfy Amazon (and have made some progress for PDF/X-1a:2001 compatibility) but have not been able to crack ink coverage yet

@BrianCriswell
Copy link
Member

BrianCriswell commented Jan 18, 2022

You mean where DTRPG requires <=240%? It requires making a special ICC with Photoshop. The easiest way to convert it is to use ImageMagick to convert RGB images to CMYK with the ICC. It's really surprising to me that DTRPG doesn't just supply an ICC.

I have a batch file that I run to convert all the RGB files and place them in a mirrored directory structure for the CMYK images. My LaTeX class then accepts a target argument that specifies whether the target is screen or PoD and selects the RGB or CMYK image folder accordingly.

The other thing you might run into is the no transparency requirement. I round the edges of my images with TColorBox, and this is implemented via alpha blending. I have to run one of the Adobe Acrobat proofing routines to flatten the images in the resulting PDF.

@timvdalen
Copy link
Author

At the risk of derailing this thread, would you be willing to share how you handle batch color profile conversion for images with transparency? If I let ImageMagick handle the -profile conversion from a png to a pdf, the resulting PDF file is broken in Acrobat.

I was able to make it work (and my DTRPG proof is ordered!), but I had to first convert all PNGs to PDF and then manually convert their color profiles in Acrobat.

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

No branches or pull requests

2 participants