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

latex output #92

Open
matsavage opened this issue May 2, 2021 · 31 comments
Open

latex output #92

matsavage opened this issue May 2, 2021 · 31 comments
Labels
discussion enhancement New feature or request

Comments

@matsavage
Copy link
Contributor

Hey, I came across this package a while ago and was really impressed,

I spent a while working on a LaTeX character sheet template, and was wondering if you'd be interested in a PR to build outputs from your package for the template I built.

https://github.com/matsavage/DND-5e-LaTeX-Character-Sheet-Template

Can't figure out how to get in touch with you other than here.

@canismarko
Copy link
Owner

Thanks for reaching out. Yeah, I'd definitely be interested, your character sheets look really nice.

One of the struggles I've had with the fillable-PDF route I'm using now is that I can't figure out how to get rich-text into the PDF fields, and this would be a fix to that, too: #3

For now, I think it's probably safest to add a new command line option for turning on your template. If it's stable, and works better than the fillable PDF route, I'd be interested in making it the default. Might also take care of this issue too: #75

FYI: I already have an option for using the same DND-5e-LaTeX-Template through the --fancy option.

@matsavage
Copy link
Contributor Author

matsavage commented Jun 16, 2021

@Tim-Jackins
Copy link
Contributor

Hello! I'm in the process of jinja-ifying the wonderful character sheet created by @matsavage so it can be rendered by this package.

@matsavage
Copy link
Contributor Author

I had the original intention of making it more like a LaTeX module, so each page could be dropped in like the monsterboxes etc in that PR I did for this project, unsure about adding dependences etc in LaTeX

@Tim-Jackins
Copy link
Contributor

Yeah, my hope was just to get the character files in here with jinja that uses the character object to build. As far as rich text goes do we have any intention to allow users to write the longer section descriptions (other features and the equipment section) with minimal markdown (ie translate text here to \textbf{text here})?

@matsavage
Copy link
Contributor Author

I believe that's already handled by the markdown syntax used in this library already

@Tim-Jackins
Copy link
Contributor

Thanks for the info. I really need to look more into this package...

@canismarko
Copy link
Owner

Sorry for the slow response. Thanks for working on this. I was looking into ways to bundle the latex dependencies in with the package, but I couldn't find a way that doesn't involve actually installing them into texlive or whatever. If you have any ideas please let me know.

The ability to parse the rst into proper latex should be all there now (#70). It uses the rst_to_latex function in latex.py. The handling of headings is a little screwy still, since it doesn't quite know how to parse different heading levels from rst to latex.

@bw-mutley
Copy link
Contributor

bw-mutley commented Jul 17, 2021

Hi there, I just want to know the state of the art regarding this. @Tim-Jackins , please let me know if you have a template running already. I've already decided to start using this template on my own sheets - it is really beautiful by the way - and I am willing to provide any help if needed. The character sheet part is straighfoward to adapt, I just see the spells list part would have to be worked a bit in order to get the corresponding fields from the docstrings.
==EDIT==
NVM, the spells part is also easy. @Tim-Jackins , just let me know how is your template so I can have a somewhat 'stardarized' form.

@canismarko , @matsavage thank you and congratulations for your work!

@matsavage
Copy link
Contributor Author

@canismarko sorry this is coming slow, I totally missed that comment from about 3 weeks ago. This point was where I sort of got stuck on this too, I think the options are either:

  • Make the character sheets a tex package and upload them to cran, which I'm not sure how to do etc
  • Package the character sheet up in the same way as has been done for dungeon-sheets and require installation in texmf
  • Include my repo as a git submodule or just copy all of the code into this project

I'm really not sure which of these is preferable

@canismarko
Copy link
Owner

If you can make the last option work, I think that would be the easiest for people using dungeonsheets since there's no need to worry about texmf or installing extra latex packages. I tried this with the D&D latex template (https://github.com/rpgtex/DND-5e-LaTeX-Template#project-install-using-texinputs), though and couldn't get it to work.

@matsavage
Copy link
Contributor Author

matsavage commented Jul 22, 2021

I'll try and have a look over the weekend with the submodule route, I think something just needs to be done with working directories or environment variables

On a linux environment with the DND template installed in examples/DND-5e-LaTeX-Template the following command worked for me:
TEXINPUTS=".:./DND-5e-LaTeX-Template:$TEXINPUTS" pdflatex wizard2_features.tex

Therefore I think the following course of action will work:

  • Set up git to import this package, and mine into some sort of submodule folder
  • Set the TEXINPUTS variable when the pdflatex (or XeLaTeX as is required for font support in my package) is run

This should then let LateX know where the required classes are and then work as expected

Edit: not 100% on how this will work on windows/mac however or if you install the module from pip
Edit2: looks like pip does support this pypa/pip#577

@Tim-Jackins
Copy link
Contributor

@bw-mutley My template is unfinished. I'm hoping to finish the back story page soon but work has picked up. I think the backstory page I have so far is enough for you to get started, check it out here. Let me know if you have more questions and I'll try to be more prompt with my reply!

@matsavage
Copy link
Contributor Author

matsavage commented Jul 22, 2021

@canismarko I got this working in the following PR #103

If you can validate that this works with pypi/pip etc, I'm happy to build out the template files, which should be able to remove the texmf etc dependancies, but as it stands, this should remove the need to install the template separately

The following worked for me:

git clone git@github.com:matsavage/dungeon-sheets.git
cd dungeon-sheets

git checkout latex_environment
git submodule init
git submodule update

python3 -m venv py37
source py37/bin/activate

pip3 install .

makesheets --fancy example/rogue2.py

Which resulted in the rogue2 template typeset in the fancy mode

@Tim-Jackins
Copy link
Contributor

Tim-Jackins commented Jul 27, 2021

@bw-mutley My template is finished and can be found here

@bw-mutley
Copy link
Contributor

Hi @Tim-Jackins , thanks for the reply. The link you provided is going to a non-Jinjafied template (dagmar.tex), is that correct? Should I work from there? (no problem at all...)

@Tim-Jackins
Copy link
Contributor

@bw-mutley Sorry for the confusion! Yes the template is not jinja-fied I just finished the page rendering in xelatex. I'm happy to do the jinja-fication but my schedule is busy if you think you can do it sooner.

@canismarko
Copy link
Owner

Thanks, everyone, and thanks for your patience with my slow reply times (I've been working 16 hour shifts 7 days per week at work recently). I got @matsavage's PR merged, with a small tweak. I bumped the version to 0.16.1 and verified that a pip install (from pypi) into a clean conda environment will build with the -F flag. Looking forward to seeing if the character sheets can work this way too.

@bw-mutley
Copy link
Contributor

bw-mutley commented Aug 5, 2021

hi there @canismarko , this merge mean @matsavage 's template is already working with dungeonsheets? I was jinjafying it last night, I am half way through. Also, in the process of reading the code, I've come with some enhancement proposals related to the way the sheet is rendered. I am just unsure where should I touch, as it would mean to change some basic classes like the character class. As an option, I could create a separate module inheriting whataver I needed from yours.

Aside from all this, I have found possible fixes to some small issues listed here, like the proper hit die summing up for multiclass.

Please give me some advice, because I am brand new to to colaborating in github. Thanks for your attention.

@matsavage
Copy link
Contributor Author

matsavage commented Aug 5, 2021

@canismarko i don’t envy those working hours. Reminds me of national facility times myself.

@bw-mutley it means I have to approve @Tim-Jackins changes to my repo to include the middle character sheet page, and then raise a PR to include it in this repo, alongside your jinja template or if you raise a PR to your template I can add the work for the submodule in there.

Maybe best to just have one PR for the templates and then another to fix those other changes you have found? I’m sure there will be some after the template to remove elements that this approach streamlines down the line?

Great to see this all coming together!

@matsavage
Copy link
Contributor Author

matsavage commented Aug 5, 2021

I may be getting ahead of things, but I sort of envisage 3 output modes:

  • pdftk of the form fillable pdf
  • LaTeX in black and white with plain background
  • LaTeX in colour with paper background

With a flag for with/without features pages for the final 2 options.

Would also be great to get character portraits in the latex version

@bw-mutley
Copy link
Contributor

@bw-mutley it means I have to approve @Tim-Jackins changes to my repo to include the middle character sheet page, and then raise a PR to include it in this repo, alongside your jinja template or if you raise a PR to your template I can add the work for the submodule in there.

Maybe best to just have one PR for the templates and then another to fix those other changes you have found? I’m sure there will be some after the template to remove elements that this approach streamlines down the line?

Great to see this all coming together!

Thanks, for the reply, Mat. I was a bit lost about the best approach since I would need to bridge the works of you and Mark. I will do the following:

  1. Finish the jinjafyied version of your template;
  2. Write a compatibility module to use it with dungeonsheets;
  3. PR them to your repo;
  4. Work on dungeonsheets fixes along the way and PR later;
  5. Write a final version of changes in dungeonsheets to include your template as an optional form and propose a PR to Mark.

@matsavage
Copy link
Contributor Author

@bw-mutley i think 3 should be a PR against this repo, but that we’ll both have something to contribute to it, so maybe you’ll have fork this repo, add the jinja template, then I can raise a PR to add the template import then you raise a PR here with both of our changes?

github seems to make this harder because of user permissions?

@matsavage
Copy link
Contributor Author

@bw-mutley or you could just follow the outline here to pull my sheets into this project, that’s all I was going to do

#103

@bw-mutley
Copy link
Contributor

bw-mutley commented Aug 5, 2021

Hey Mat, I think github makes things easier, it is just me who must to get along :)

or you could just follow the outline here to pull my sheets into this project

Thats what I was trying to do, but since you added this suggestion, I guess I didn't understand well.

you’ll have fork this repo, add the jinja template, then I can raise a PR to add the template import then you raise a PR here with both of our changes

I will follow this option then, seens more clear to me. In this case I would add the changes to the fork I've made from this repo and wait for you to raise the PR before adding my last two changes, did I get it right?

@matsavage
Copy link
Contributor Author

@bw-mutley sounds good. Let me know when you’re done and I’ll get to it 👍

@matsavage
Copy link
Contributor Author

@bw-mutley I have gotten quite a lot of the way along with this today, the main work being converting my latex template to be a class so that it can be imported properly, I am still coming across a couple of issues, namely:

  • The custom font I am using is causing a pain because of paths
  • There is an element of the first page text input which is giving the following error when compiling though python:
\environment DndTable code ...ableBody \rowcolors 
                                                  {1}{}{\l__dnd_table_color_...
l.92 }

Just keeping you up to date with changes, I spent a lot of today doing this, and am going to do something else for the rest of my weekend.
I just but don't want you repeating work, I haven't done anything on the actual templating, just added all of the variables to the preamble.tex file, which you seemed keen on working on?

druid1.pdf

changes here:
https://github.com/matsavage/dungeon-sheets/tree/latex_template

@bw-mutley
Copy link
Contributor

hi there, @matsavage . I was circunventing this path problem using os.chdir to your template directory just before compilation. I don't think there will be repeated work, it won't be hard to adapt to your new files.

@canismarko
Copy link
Owner

Sorry for the delay. I finally had time to look at @bw-mutley's PR. Thanks for all the hard work. I added a command line option "-T" to use the template. I actually can't use the template on my computer since I don't have Kalam font installed, but since it gets to that point I'm assuming the rest of it works okay.

@bw-mutley
Copy link
Contributor

Glad to be of help!

@matsavage
Copy link
Contributor Author

matsavage commented Oct 1, 2021 via email

PJBrs added a commit to PJBrs/dungeon-sheets that referenced this issue Jun 30, 2024
This patch adds the MSavage latex template as a submodule
to dungeonsheets, adds it to the TEXINPUTS environment
and adds TTFONTS environment variable to find the kalam
font.

Furthermore, make the MSavage latex template part of the
tests in the github workflow.

Remove babel support from the MSavage latex template,
otherwise latex will complain about missing languages
(alternatively, we could add the languages directory from
the dnd class to pyproject.toml).

The latest version of the MSavage latex template adds
automatic text scaling so that text fields no longer overflow with
longer inputs.

This fixes canismarko#92
PJBrs added a commit to PJBrs/dungeon-sheets that referenced this issue Jul 4, 2024
This patch adds the MSavage latex template as a submodule
to dungeonsheets, adds it to the TEXINPUTS environment
and adds TTFONTS environment variable to find the kalam
font.

Furthermore, make the MSavage latex template part of the
tests in the github workflow.

Remove babel support from the MSavage latex template,
otherwise latex will complain about missing languages
(alternatively, we could add the languages directory from
the dnd class to pyproject.toml).

The latest version of the MSavage latex template adds
automatic text scaling so that text fields no longer overflow with
longer inputs.

This fixes canismarko#92
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants