Perform separate compilation of Latex documents - latex

When compiling latex documents the compiler emits a lot of "object" files. This clutters the directories I'm working on and it difficults the use of VCS like SVN. When I work with C++ code I have separate directories for the code and the objects, I can run make on the source directory but the .o files go to the build directory.
Is there a proper way to perform this separate compilation with Latex documents? Can it be done by using Makefiles or by passing options to the latex compiler?
Thanks

You can use:
pdflatex --output-directory=tmp file.tex
and all the files will be stored in the folder tmp (pdf included).
Because this is not an optimal solution, I made my own tool, pydflatex, that compiles the LaTeX source by stashing away the auxilliary files (using the trick above), and brings the pdf back to the current directory, so after compiling you only have file.tex and file.pdf in your directory. This plays very well with version control.

I can't help much with LaTeX (having last user it seriously 20 years ago;-), but for Subversion, you should read up on the svn:ignore property -- it makes it easy to ignore files with extensions you do not want to version (object files, bytecode files as Python can often put in the same directory as the sources, backup files some text editors use, &c).

Latex generates the temporary files in the directory where the main document is located. If you want the contents to be placed in a different location, try with a main file like below.
\documentclass{article}
\input{src/maindocument.tex}
Using this method, you could maintain a directory structure like below
/
main.tex
/src
maindocument.tex

Two options, besides the above.
Use Lyx: it looks after the separate files. I think it copies the Latex file over to its own private directory and runs latex on it. In any case, nothing is created in the current directory.
Use a makefile or one of the special Latex make programs, and have your regular targets run make clean.

Related

Generate Table of Contents (ToC) automatically

I have a Latex project that is including multiple PDFs. These PDFs are added in the final document through the includepdf tag when the project is compiled over Overleaf. My question is can Latex automatically generate a ToC from included PDFs, i.e., can it automatically read the \section \subsection tags from the included files and automatically generate it? Or maybe this is only possible if I included the separate project or sources into the final solution and compile that.
Your help is so welcome!
Including a rendered pdf file in your project would make you limited in accessing details of those documents. You will then only be able to select specific pages or add some content on specific places of those files (e.g. your own page numbers).
Since you have access to those projects, best is to nest those raw tex files under your current project using one (or a combination) of the following methods:
Input command: \input{foo.tex}: in this case the input file mustn't be a separate project (no \begindocument and \enddocument in it)
Include command: \include{foo.tex}: very similar to input command but a bit limited about nested includes.
import package: very similar to input and include commands but allows nested imports and also accepts a different logic for path resolution on its input (i.e. it accepts relative path to the file from where it is called).
subfiles package: In this case the subfile can have its own document body and is able to be rendered separately. The subfiles would use the preambles of your main project.
standalone package: Similar to subfiles but the main project would use the preambles of your subfiles in this case.
Overleaf nicely allows you to add files from another project which is the best choice when the other file is still being developed in a separate project. In this case, the file remains under control of the other project.
For further info, here is a very nice guide on how to write modular documents in latex and here is a brief tutorial on subfiles and standalone.

How to keep generated source code for proto files in bazel?

I have studied https://blog.bazel.build/2017/02/27/protocol-buffers.html . The project I want to hack on is written in Go. At the moment, if I run the build command I can see the compiled binary but I don't see the *.pb.go files anywhere. I want to keep the generated *.pb.go files in the same folder where *.proto files are so that my IDE (Intellij Goland) can find and index them.
Can you please help me how to get this working? If you can show me how to do that for the github.com/cgrushko/proto_library project, I should be able to try that in my particular project.
Bazel will not output generated files (such as .pb.go) into the source tree. They go into the output directories (bazel-out/<config> or bazel-genfiles/<config>). Temporary solution might be to add those as source roots to goland. The real solution is to use https://ij.bazel.build/. It has some Go support, and the team is actively working on improving it.

How to add library paths in Delphi 10

I am trying to install GLscene but getting problems with the source file locations.
It says in the install instructions to add the GLscene source directories into the global library path in tool/options/Delphi options/Library, which I have done but it has no effect.
I can add the source directories into each package project directory and it then compiles, but I would rather have it accessible globally.
The GLscene library items I have entered are,
C:\Users\Andy\Documents\Embarcadero\Studio\Projects\GLScene_VCL\Source
C:\Users\Andy\Documents\Embarcadero\Studio\Projects\GLScene_VCL\Source\Shaders
C:\Users\Andy\Documents\Embarcadero\Studio\Projects\GLScene_VCL\Source\DesignTime
Which are all correct,
anybody know any reason why the compiler can't find the files in these directories?
The compiler will search for source files on the library path. Note that there are separate library paths for different targets, e.g. Win32, Win64 etc.
If you have source files that cannot be found, then they are not in the library path that you specified.
Personally I don't like the approach of using search paths for source files. I like everything under my project directory so that I can check out from my VCS and have everything I need to build right there. A search path based approach makes serious development very difficult because you cannot maintain branches. What if you have old versions to maintain that use old versions of your libraries?
Well this is a bit late but it could help someone else.
Try and add the paths to both the Library Path and the Debug DCU Path.
Recent Delphi versions have different build configurations for Release and Debug and my guess is that the Debug configuration only searches in the Debug DCU Path.

Qmake using separate folders for sources and headers without modifying .pro

I'm want to compile meshlab(http://sourceforge.net/p/meshlab/code/HEAD/tree/) and put the generated file outside the source directory to keep the source clean. Is it possible to just specify a build directory as the way in cmake?
The answer in this post Qmake and Make using separate folders for sources and headers, requires to modify the .pro file and doesn't work in my case. Users may want to specify the build dir path as they like, right?
I think what are trying to do is a QMake Shadow Build. This question about Manually Configuring Shadow Builds in QMake should help you.

Adding components to a component folder

I'm working on a Delphi project and I want to add a parser to it. The parser comes with components that should be added to the project
So it works great if I add the files to the same folder that my project is in, but I would like it to be in a separate components folder (to keep it cleaner, since I'm not going to be modifying those files anyway).
However, when I add create a components folder and add the files there, when I add it to the project through delphi, it has trouble finding the files. So it adds the .psu files to the right folder, but it says it can't find the unit 'Calculator', for example, until I copy the Calculator.dcu file from the component directory to the source directory.
How do I tell Delphi to look for those files where I put them?
Thanks
You have some options:
Add the units folder to the Projects' Search Path (Menu: Project\Options...) - only affects the project you're working now.
Add the units folder to the Environment's Library Path (Menu: Tools\Options...\Environment Options\Delphi Options\Library - Win32) if you want all projects in this ide install to find that units (not only the project you are working).
Just to complement: if, in the near future, you add components to your pallete and the compilation fail not finding the units; you'll have to update your system path as well. For details give a search on SO on this, as this is a common source of questions on the delphi tag... ;-)
Take a look at the Search Path for the project in the project options. Make sure your .pas and/or .dcu files are in that search path, i.e. add the folder in which the units are to your project's search path.

Resources