Insert contents from an external text file into a latex file - latex

I have a text file in the working directory of a latex document. I have created sections in the latex document. I would like to insert the contents of the text file in latex.
My reason for doing so is to simply the latex file into simple parts so that it is not over crowded. The text file may contain equations as well.
There is a verbatim package but I am not able to install it via the package manager in Miktex. I tried to install it via mpm --install verbatim in the command line but it cannot find the package.
I am not sure if that is the right way. I hope someone can guide me in the right direction.

I am writing this answer with the help of comment from NickD.
In the same working folder create a separate file foo.tex
In the main file, where you need it imported, type in the code \include{foo}
After compiling it, you should be able to see the imported contents from foo.tex

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.

Importing .tex table to lyx using tex2lyx

I'm writing a document in lyx and I have tables that are .tex files. I usually import them via the menu, but I would like to import them directly using a snippet of tex code in the lyx file using directly tex2lyx in the document.
How do I do it? Thanks in advance.
Just go to Insert > File > Child Document and select your .tex file. You can have it show a preview if you want. For more questions, please ask on tex.stackexchange.com

Qt5.5 qmake don't generate proper .pro file

Currently, I'm using Qt5.5 with Visual Studio 2015.
After making UI files, I want to make a .pro file using the command "qmake -project" (VS2015 environment is set). And the .pro file is generated.
After that I pass "qmake -tp vc qtexample.pro " to create visual studio project. The project is created without problem.
When I'm trying to build the project, it shows me a lot of linking errors. After googling the problem, I found a solution - to add this line "QT += core gui widgets" in the .pro file.
So, my question is: Why didn't qmake write that line in the .pro file? What's wrong here? Should I always add manually this line in the .pro file? Is there any way to avoid manually adding the line?
core and gui are added by default, however, widgets is not. This info is clearly stated in the documentation.

recompile/rebuild Delphi 5 code using .dpr file

I am trying to recompile/rebuild an old application program developed on Delphi5. I used the same Delphi5 software on an XP computer.
I did some minor corrections to the codes of a couple of forms and units. When I recompile using the .dpr file it comes with a fatal message: File not found System.pas
I added in .dpr file on the link path to this file BP folder. No success and the same message. Any clue will help.
Probably Library Path is broken after running some buggy component installer. In modern IDE's look for Tools -> Options -> Library -> Library Path from main menu (should be slightly different for Delphi 5).
System.dcu file lives in $(BDS)\Lib path for Delphi 2007.
The "File not found System.pas" error often isn't really because it can't find system.pas. It's some other problem that manifests as this error.
It can be:
Duplicate Path entries in the Library Path.
Too many entries in the Library Path - I think the limit is 99.
Path to a package in Library Paths too long.
Path to a package in Library Paths corrupt.
Environmental Variables not set correctly.
and possibly more if you Google "system.pas not found"
Marjan is right.
But also add ${DELPHI}\LIB\OBJ
If you still have a dcc32.cfg with the project, or a .cfg with the project, open it up to see if the settings in there are correct. Otherwise delete the .cfg or edit it to reflect the proper path to the bin and bin\obj directories.
A .dpr file is the main project file for a Delphi 2,3,4,5,6,7 project.
You have not given any details like WHAT WAY OF BUILDING SOMETHING of delphi you're using (the code is Delphi 5 level code, but you are not telling me for example, if you built the project inside the Delphi IDE or from the command line compiler DCC32), and what other files you have installed. You haven't mentioned if the library paths and so on are configured (either for the IDE, or for the command line environment, both of which are separate tasks).
An inability to find System.pas suggests to me that you might be running the command line compiler (Dcc32) instead of the IDE to build the project, and you have forgotten to mention that. That usually means you have to set up the Options (dcc32.dof) file for Delphi, so that command line building with Dcc32 can work.
What exactly do you mean by "When I compile with the .dpr file"? Instead of making people guess, show the commands you typed, exactly, and the error message, exactly. If it helps, use screenshots or text grabs.

Perform separate compilation of Latex documents

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.

Resources