rened / LaTeX.jl

Create LaTeX documents from within Julia, including image handling
Other
54 stars 15 forks source link

Register to General ? #18

Open jonathanBieler opened 4 years ago

jonathanBieler commented 4 years ago

Hey @rened, it looks like this package wasn't registered to General. If you want I can do the update. It would be nice if you could add me as a collaborator, otherwise I'll be bothering you quite a bit :

https://help.github.com/en/github/setting-up-and-managing-your-github-user-account/inviting-collaborators-to-a-personal-repository

famura commented 2 years ago

I am quite new to Julia, so please excuse this beginner question. Is this issiue why I get

(docs) pkg> add LaTeX
ERROR: The following package names could not be resolved:
 * LaTeX (not found in project, manifest or registry)
jonathanBieler commented 2 years ago

@famura this package is not registered and not up-to-date. I got a PR for updating it but it wasn't merged, you can try this, it might work :

]add https://github.com/jonathanBieler/LaTeX.jl.git

famura commented 2 years ago

@jonathanBieler thank you for the explanation. I tried your suggestion and it worked 👍

jonathanBieler commented 2 years ago

Maybe I should register my fork, I still find this package useful at times.

famura commented 2 years ago

Sounds like a good idea. That would make it easier to run it within gh workflows.

famura commented 2 years ago

This is a bit off-topic @jonathanBieler, but do you know how I can compile a tex-file from Julia? I know that this package is more about creating the latex content programatically, however in my case there is already a main.tex and I just want to compile and display a pdf from it.

famura commented 2 years ago

I tried LaTeX.openpdf(joinpath(PROJECT_ROOT_DIR, "paper", "main.tex")) but that crashed, and I assume that the latex argument of makepdf is expecting sth else than a tex-document.

jonathanBieler commented 2 years ago

@famura I think running that line should do it (with texname being the path to your tex file) :

https://github.com/rened/LaTeX.jl/blob/master/src/LaTeX.jl#L113

famura commented 1 year ago

In the end, I solved my problem with your hint, but without LaTeX.jl :)

I have a page called "paper.md" which dispalyes the current WIP build of the paper. This file, just like the rest of the doc lives in the docs folder which is located in the ROOT_DIR. The paper is build in the paper folder which is also located in the ROOT_DIR. Finally, the resulting pdf is displayed in the "paper.md" file which is included in the doc just like Documenter.jl does it with other markdown files.

```@eval
import MyProject

cd(joinpath(MyProject.ROOT_DIR, "paper"))

output = read(`pdflatex -shell-escape -halt-on-error main.tex`,String)
occursin("Error:", output) && println(output)

cp(joinpath(MyProject.ROOT_DIR, "paper", "main.pdf"), joinpath(MyProject.ROOT_DIR, "docs", "build", "main.pdf"))
nothing
```@raw html
<object data="../main.pdf" type="application/pdf" width="900px" height="1100px">
    <embed src="../main.pdf">
        <p>This browser does not support PDFs. Please download the PDF to view it: <a href="../main.pdf">Download PDF</a>.</p>
    </embed>
</object>