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

Explore whether we can change file path structure for LaTeX files #85

Closed
jmshapir opened this issue Oct 20, 2023 · 25 comments
Closed

Explore whether we can change file path structure for LaTeX files #85

jmshapir opened this issue Oct 20, 2023 · 25 comments
Assignees

Comments

@jmshapir
Copy link
Contributor

In LyX we use paths relative to the LyX file:

filename "../../source/figures/gdp_educ.lyx"

In LaTeX we use paths relative to the root:

\bibliography{source/paper/References}

The result is that, in a repository configured according to the Template, it's harder to compile manually in LaTeX than it is in LyX.

Can we investigate whether there is a robust way to modify the builder so that we can use the same path structure in LaTeX that we use in LyX?

Thanks!

@rcalvo12
Copy link
Collaborator

Per meeting: Should look into solution offered by this stack exchange thread.

ew487 added a commit that referenced this issue Oct 26, 2023
@ew487
Copy link
Contributor

ew487 commented Oct 26, 2023

@jmshapir I made some changes to the tex files so that commenting out line 17 on the main file should allow you to compile by clicking the button in the tex editor. Do you think that works?

@rcalvo12
Copy link
Collaborator

@ew487 The solution you implemented worked for me! I was able to compile using scons from the root and then, once I commented out line 17, was able to compile from within the document.

@ew487
Copy link
Contributor

ew487 commented Oct 26, 2023

@rcalvo12 Great! Thank you for checking!

ew487 added a commit that referenced this issue Oct 26, 2023
@jmshapir
Copy link
Contributor Author

@ew487 thanks!

When trying to compile with line 17 commented out, I hit the error below, though it may be unrelated to the file paths. (Given that @rcalvo12 didn't hit the error I suspect we shouldn't worry about it just now.)

In terms of the implementation, is there a reason you prefer to specify a \dir macro rather than universally specifying the input path as suggested here?

I can see tradeoffs either way so am curious to know how you are thinking about it, thanks.

Sorry, but miktex-epstopdf did not succeed.

The log file hopefully contains the information to get MiKTeX going again:

  C:\Users\Jesse Shapiro\AppData\Local\MiKTeX\miktex\log\miktex-epstopdf.log

! Package pdftex.def Error: File `../../output/analysis/plots/gdp_educ-eps-conv
erted-to.pdf' not found: using draft setting.

See the pdftex.def package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.8 ...aphics{\dir/output/analysis/plots/gdp_educ}
                                                  \medskip{}

@jmshapir
Copy link
Contributor Author

(Also, just confirming that I was able to resolve the epstopdf error that I reported in #85 (comment).)

@ew487
Copy link
Contributor

ew487 commented Oct 27, 2023

@jmshapir I didn't use the universal input path because I couldn't get it to work. But I didn't try very hard so I will give it another go and get back to you on the pros and cons!

@jmshapir
Copy link
Contributor Author

@ew487 thanks and sounds good! Of course if you get stuck trying the universal input path, feel free to pause and let me know so we can reconsider whether it's worth investing in that direction.

ew487 added a commit that referenced this issue Oct 27, 2023
@ew487
Copy link
Contributor

ew487 commented Oct 27, 2023

@jmshapir I implemented the universal input path in 610000b. I think the main advantage is that the the user does not need to comment out anything to run with scons or compiling manually. I think some disadvantages are that 1) we have to remember not to duplicate file names, 2) if we create a new file, we have to remember to specify its location in two places, and 3) we will be searching folders with ../../ that we have no idea what they look like.

jmshapir added a commit that referenced this issue Oct 27, 2023
@jmshapir
Copy link
Contributor Author

@ew487 thanks!

That solution looks interesting.

A couple things:

  1. In 88aaf0c I split the path statement across two lines. The parallelism might make it easier to remember to specify both (re: your point 2), and to disable the local compile paths if they cause errors (your point 3). Let me know if you see any meaningful downsides to splitting this way.
  2. I tried just folding the graphics paths into the input@path argument but it didn't seem to work. Any idea why? Is it because graphicspath is storing the graphics path in a macro that is separate from the input@path macro?

ew487 added a commit that referenced this issue Oct 27, 2023
@ew487
Copy link
Contributor

ew487 commented Oct 27, 2023

@jmshapir I don't see any meaningful downsides to splitting that way. Regarding the graphicspath, I moved it into the input@path in b3dc300. I think part of the problem was that graphicspath takes on the value of input@path at the time that graphicx is loaded, so I moved the loading of the package later. I'm not sure why but I also had to add an extension to the filename when using includegraphics in the child document.

ew487 added a commit that referenced this issue Oct 27, 2023
ew487 added a commit that referenced this issue Oct 27, 2023
This reverts commit bc0c88c.
@ew487
Copy link
Contributor

ew487 commented Oct 27, 2023

@jmshapir I also tested a slightly different implementation in bc0c88c that avoids the duplicate filename issue, but the tradeoff is that it searches the entire repository.

@jmshapir
Copy link
Contributor Author

@ew487 thanks!

@jmshapir I don't see any meaningful downsides to splitting that way. Regarding the graphicspath, I moved it into the input@path in b3dc300. I think part of the problem was that graphicspath takes on the value of input@path at the time that graphicx is loaded, so I moved the loading of the package later.

Nice, thanks.

I'm not sure why but I also had to add an extension to the filename when using includegraphics in the child document.

Specifying the extension doesn't seem so costly to me, but I would like to make sure this works with EPS (in addition to PNG).

@jmshapir I also tested a slightly different implementation in bc0c88c that avoids the duplicate filename issue, but the tradeoff is that it searches the entire repository.

That makes sense. I see some merit in that alternative but as of now I think I favor the more explicit approach (as of b3dc300) as it narrows the search a bit and so might result in fewer side effects.

@ew487
Copy link
Contributor

ew487 commented Oct 27, 2023

@jmshapir Regarding eps files, it does not work as is, so I can look into that.

@jmshapir
Copy link
Contributor Author

@ew487 understood thanks. If we're not able to get an implementation that works with EPS this way we can always revert to making graphicspath explicit.

@ew487
Copy link
Contributor

ew487 commented Oct 31, 2023

@jmshapir I think the issue is with pdflatex, since when I manually compile with xelatex the eps files work. Would you or @rcalvo12 be able to confirm this?

@jmshapir
Copy link
Contributor Author

@rcalvo12 can you check this?

If @rcalvo12 confirms the issue, I think we can just revert to making graphicspath explicit.

ew487 added a commit that referenced this issue Oct 31, 2023
@jmshapir
Copy link
Contributor Author

jmshapir commented Nov 5, 2023

@ew487 I had a few minutes to test this myself and I can confirm that I get an error compiling locally with pdflatex but not with xelatex.

I'm reluctant to design the template so that pdflatex does not work out of the box, so am inclined to revert to the solution with input@path+graphicspath. Can you implement so I can take another look over that implementation?

Thank you!

@rcalvo12
Copy link
Collaborator

rcalvo12 commented Nov 6, 2023

@ew487 I had a few minutes to test this myself and I can confirm that I get an error compiling locally with pdflatex but not with xelatex.

@ew487 Just want to confirm that I also tested this and had the same results as both you and @jmshapir.

@jmshapir
Copy link
Contributor Author

jmshapir commented Nov 7, 2023

@rcalvo12 thanks!

@ew487 given that, let's revert to the plan below from #85 (comment), thanks!

I'm reluctant to design the template so that pdflatex does not work out of the box, so am inclined to revert to the solution with input@path+graphicspath. Can you implement so I can take another look over that implementation?

ew487 added a commit that referenced this issue Nov 8, 2023
ew487 added a commit that referenced this issue Nov 8, 2023
@ew487
Copy link
Contributor

ew487 commented Nov 8, 2023

@jmshapir It should be reverted now!

jmshapir added a commit that referenced this issue Nov 8, 2023
@jmshapir
Copy link
Contributor Author

jmshapir commented Nov 8, 2023

@ew487 thanks! I fiddled with it a bit locally and it seems to behave as expected.

Can you compile the repo and open a pull with @jmshapir as reviewer?

@ew487
Copy link
Contributor

ew487 commented Nov 8, 2023

Thread continues in its pull request #86

jmshapir added a commit that referenced this issue Nov 9, 2023
ew487 added a commit that referenced this issue Nov 10, 2023
jmshapir added a commit that referenced this issue Nov 10, 2023
@jmshapir
Copy link
Contributor Author

Interim summary: We found an approach we like better so we are going to abandon the branch 85-explore-whether-we-can-change-file-path-structure-for-latex-files and open a new pull for 85-testing.

jmshapir added a commit that referenced this issue Nov 13, 2023
…re for LaTeX files (#87)

* #85 Simplification to build_latex.py

* #85 Edit paths

* #85 Star command

* #85 Add if statement

* Revert "#85 Simplification to build_latex.py"

This reverts commit 802e4f8.

* #87 Push of run logs

---------

Co-authored-by: Richard Calvo <97416734+rcalvo12@users.noreply.github.com>
Co-authored-by: ew487 <emwang@hbs.edu>
@jmshapir
Copy link
Contributor Author

Summary: In this issue we developed and tested a solution to allow users to compile TeX files both manually and via scons without having to intentionally toggle the document. Changes brought to main in 204def9.

@ew487 ew487 mentioned this issue Dec 15, 2023
4 tasks
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

Successfully merging a pull request may close this issue.

3 participants