Git Product home page Git Product logo

Comments (4)

gplssm avatar gplssm commented on August 16, 2024

i would love to have graphics support in this nice python package. first level graphics support would achieved if it would be possible to load additional latex packages. if haven't found any way to add additional to the document. neither in the examples nor in the code of pylatex. do you have any recommodations to me?
i would appreciate!

from pylatex.

JelteF avatar JelteF commented on August 16, 2024

Packages can be added to like this:

doc = Document()
doc.packages.append(Package('fullpage'))

You can even pass it keyword arguments specified here:
https://github.com/JelteF/PyLaTeX/blob/master/pylatex/package.py
The argument names corespond to this output: \base[option]{name}
That way you can even change the base to a graphics command and use that instead of an actual string. Like this:

Package('chick.png', base='includegraphics', option='scale=0.5')

I hope this helps. Actual graphics objects will probably not happen soon, since I mostly add to this library whenever I need something extra. And I won't see myself using very advanced features that won't be achievable by using the method described above. I might make a Command object though, so the Package object doesn't have to be misused for commands.

from pylatex.

gplssm avatar gplssm commented on August 16, 2024

Thanks for the quick reply.

The hint, how to add packages in the preamble works fine for me! Thanks
for that!

Using the Package('chick.png', base='includegraphics',
option='scale=0.5') method to add an "\includegraphics"-statement,
doesn't work for me in that way, because I'm just able to add the
"\includegra.."-statement in the preamble, which doesn't make sense in
terms of including a figure in the document.

For now I have a workaround with just adding a plain text insertation of
"\includegraphics..." by appending it to the section-object similiar to
text, tables, etc.

If I'll have enough time, I would like to contribute a proper figure
method to pylatex. But I can't promise that, because it takes a while
for to code this in a smart way...

Am Mittwoch, den 05.11.2014, 23:40 +0100 schrieb Jelte Fennema:

Packages can be added to like this:

doc = Document()
doc.packages.append(Package('fullpage'))
You can even pass it keyword arguments specified here:
https://github.com/JelteF/PyLaTeX/blob/master/pylatex/package.py
The argument names corespond to this output: \base[option]{name}
That way you can even change the base to a graphics command and use
that instead of an actual string. Like this: `Package('chick.png',
base='includegraphics', option='scale=0.5')

I hope this helps. Actual graphics objects will probably not happen
soon, since I mostly add to this library whenever I need something
extra. And I won't see myself using very advanced features that won't
be achievable by using the method described above. I might make a
Command object though, so the Package object doesn't have to be
misused for commands.


Reply to this email directly or view it on GitHub.

from pylatex.

JelteF avatar JelteF commented on August 16, 2024

What I meant by the chick example is that code like this should work:

doc = Document()
doc.packages.append(Package('fullpage'))
doc.append('This is a picture of a chick:')
doc.append(Package('chick.png', base='includegraphics', option='scale=0.5'))

Note: I haven't tested this.

Btw, the source code is not that big or difficult. So it shouldn't be to hard hard to create a includegraphics thing, but I'd rather have a more general way to do commands.

Something with a syntax like this:

Command('includegraphics', option='scale=0.5', argument='chick.png')

It would be nice if it could also accept lists of arguments or options so stuff like this would be possible:

\randomcommand[a][b]{'arg1'}{'arg2'}

from pylatex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.