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

Fixed research-paper Makefile #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Renato776
Copy link

The Makefile for the research-paper example had the extensions in the target parameter (-t) and needed to be in the from parameter (-f) so they were moved accordingly.
The pdflatex compilation of the main.tex file was performed twice so I removed the extra compilation steps.
Also redirecting both stderr & stdout to /dev/null was triggering a bug where it hanged after compilation during a long period of time, so I changed it to clean only the stdout & the bug was removed.
That's all, thank you for the examples. Really appreciate your hard work!

@kikofernandez
Copy link
Owner

thanks for the PR. I agree with you, the -f and -to could be moved. I am not sure that it causes any issue though.

  1. Could you compile it even with this mistake?

I run on OSX and I had to compile twice the TeX file to get the biblio in place. If not, it shows question marks ??.
2. Are you running on OSX as well?
3. Did you check that the biblio can be read correctly?

BTW, thanks for the update of the .gitignore

  1. Finally, I think your PR includes a bunch of files that should not be there, such as the TeX file and .aux files.

I would like to accept the PR. Could you please reply to questions 1 -- 4 before we can establish what we keep and what to clean up?

I would love to keep:

  • Makefile (order of arguments),
  • .gitignore
  • pdflatex single compilation, but as I said, I think the biblio is not generated correctly with a single pdflatex compilation.

Thanks for the time!

@Renato776
Copy link
Author

Thank you for reading and taking the time to evaluate my PR! Let me answer questions 1 -- 4.

  1. Could you compile it even with this mistake?
    No, I wasn't able to. Pandoc would refuse to produce the target LaTeX file. The exact error was
The extension tex_math_dollars is not supported for LaTeX
make: *** [Makefile:9: paper] Error 23

This happened because of the extensions specified on the original Makefile for the target language:

  • raw_tex
  • tex_math_dollars
  • citations.

All of those extensions are actually built-in features of LaTeX so it makes sense for Pandoc not to support them for LaTeX. Those extensions make much more sense when applied to Markdown, since most Markdown specifications don't support those features by default.
As you said, I don't think the order of the arguments causes any issue and I think we should keep the order as it is, however the extensions applied to the languages are the ones we should move.

  1. Are you running on OSX as well?
    No, I'm currently on Ubuntu and the bug I mentioned where it hanged after compilation, I actually figured out exactly what happened.
    The bug actually made a lot of sense, the issue was with the &> operator. This operator is intended to redirect both, the standard output and standard error to the specified location. In the original Makefile the location being /dev/null. However, this operator is only implemented in Bash and zsh. While those are arguably the most used interactive shells out there, and with zsh being the default shell for OSX it makes a lot of sense to use this operator for such task. However, other shells like sh, khs, csh, and others don't implement this operator. In order to make Makefiles compatible with most Unix-like systems Make actually doesn't run the commands in its Makefile using the user's shell, instead it runs all the commands using sh. sh like stated above doesn't implement the &> so instead, it treats this operator as separate symbols & and > The resultant action being detaching the current command and running it in the background while executing > /dev/null alone. Since it uses > as a separate command it is ran without an argument and as a result nothing gets printed to /dev/null, so in the end it does 'compile LaTeX file in the background and print nothing to nowhere'. It actually wouldn't be much of an issue, however since we are executing several commands in order (compile LaTeX, compile biblio and re-compile LaTeX) detaching them causes all three of them to run in parallel! The output of executing this 3 commands in parallel causes unwanted or unexpected behavior.
    I'm not an expert on Mac internals, but I'm guessing that if it works on your end is probably because you configured Make to run its commands using your user's shell instead of the default sh; another workaround could be that Mac symlinked sh to zsh but that's unlikely. So, the point is using this operator might work for some users but will generally not work for most users that run a normal Make since those are executed with the more universal sh. This is why I removed the &> operator (Bash and zsh specific) and changed it for the sh compliant > /dev/null 2>&1. This way it will run on whatever shell you are using, be it Bash, zsh or sh and the behavior will be as expected.

  2. Did you check that the biblio can be read correctly?
    No, the biblio can't be read correctly if you keep the Makefile I suggested. As you said we actually need to compile the TeX file twice in order to get the biblio in place. The first time is to tell bibtex about which citations are used in the paper so it can know which citations to include, then we compile the biblio and then we need to compile it a second time in order to apply the new biblio. So yeah, I actually forgot about this process when I submitted the original PR and removed the second compilation step.
    My bad, however I have pushed a third commit fixing this issue.

  3. Finally, I think your PR includes a bunch of files that should not be there, such as the TeX file and .aux files.
    Indeed, newbie mistake there. I actually just blindly added . before the commit when I should've just added the Makefile since it was the only change I was interested in submitting and not the actual output of the compilation or the auxiliary files. I'll take more care on what gets added and tracked from now on before making any commit. So please ignore all of those extra files out of my PR.

Alright, with all of those questions out of the way I'd suggest:

  • Merging the .gitignore (glad you liked it)
  • Updating the Makefile
  • Discard the rest

That's all, thank you again your time and sorry for my late reply (I actually didn't get notified, but I'll keep an eye manually now).

Also, please make sure to check the Makefile on my latest commit since the one I originally suggested wouldn't have worked properly (because of the missing compilation step after compiling the biblio).

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 this pull request may close these issues.

2 participants