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

usage of options #19

Closed
ZUNJI opened this issue Apr 28, 2019 · 3 comments
Closed

usage of options #19

ZUNJI opened this issue Apr 28, 2019 · 3 comments

Comments

@ZUNJI
Copy link

ZUNJI commented Apr 28, 2019

Dear saadq, I find that there exist several options to be loaded, but I cannot find any documentations about the usage of these options (a concrete example like how to set fonts will be great).
Thx!

@saadq
Copy link
Owner

saadq commented Apr 28, 2019

I am currently working on v3 of node-latex which is a complete rewrite, and I will hopefully add examples of each option usage in there. For now, here is how you would use some options:

Let's say you had a folder structure like this:

.
├── doc.tex
├── fonts
│   ├── lato
│   │   ├── Lato-Bol.ttf
│   │   ├── Lato-BolIta.ttf
│   │   ├── Lato-Reg.ttf
│   │   └── Lato-RegIta.ttf
│   └── raleway
│       ├── Raleway-Bold.otf
│       ├── Raleway-ExtraBold.otf
│       ├── Raleway-ExtraLight.otf
│       ├── Raleway-Heavy.otf
│       ├── Raleway-Light.otf
│       ├── Raleway-Medium.otf
│       ├── Raleway-Regular.otf
│       ├── Raleway-SemiBold.otf
│       └── Raleway-Thin.otf
└── inputs
    └── texstyles.cls

To include these fonts when running latex, you just need to include the path to a toplevel directory which they are in. Something like:

const latex = require('node-latex');
const path = require('path');
const fs = require('fs');

const texDocPath = path.join(__dirname, 'doc.tex');
const inputsPath = path.join(__dirname, 'inputs');
const fontsPath = path.join(__dirname, 'fonts');

const input = fs.createReadStream(texDocPath);

const pdf = latex(input, {
  fonts: [fontsPath],  // You can put multiple paths in here if you have fonts in different places
  inputs: [inputsPath] // Same thing for your TEXINPUTS
});

// Do something with pdf...

If you still have issues with usage, please comment a code example here and I can help you debug. Closing for now though.

@saadq saadq closed this as completed Apr 28, 2019
@ZUNJI
Copy link
Author

ZUNJI commented Apr 30, 2019

Thanks for your detailed instruction which is very helpful!

@EloHailwidis
Copy link

Hello @saadq !
Thanks for your work ;)

I use the options.fonts like you described it, but how can I set the main font in my .tex file ?
I use \setmainfont but I get The fontspec package requires either XeTeX or LuaTeX to function...
Should I set options.cmd ? I use pdfLatex as default, and I'd like to keep it that way.

Thanks !
(Maybe I should open an other issue instead of commenting on this one. Let me know if you want me to do so and delete this comment.)

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

3 participants