How to include a file in LaTeX wihout causing a newpage - latex

I hope, this question is not too offtopic.
I have a bigger school project which involves some documentation. The documentation is a LaTeX file, and looks like this:
...
some explanation
\section {someCode}
\include{someCode.hs}
some explanation
...
The files someCode.hs.tex are auto-genereated from their corresponding .hs-Files using Pygments and a Makefile.
The Problem is: Each time, I include something, a pagebreak is inserted before. This is neither expected nor wanted. I googled, but found no answer. Any ideas?

Use \input instead of \include.

Related

How to replace Sphinx cover page when making a PDF

I need to change the cover page of a Sphinx-generated latexpdf from RST.
How can I do that without modifying the Sphinx package itself?
I've noticed latex_preamble in the conf file but that only seems to append things. If that is the way an example would be helpful. Right now whatever I do only seems to add to rather than remove the cover page.
Found the answer and posting it here for anyone else who is interested.
In the conf.py file add the following entry:
"maketitle": "\\input{your_cover.tex}"
where your_cover.tex is your LaTeX file you want to be the cover.

knitr/rmarkdown/Latex: How to cross-reference figures and tables in 2 different pdf files?

I'm trying to write a scientific article and the associated supplementary materials entirely in RStudio with rmarkdown.
It seems clear that book down is the way to go to cross-reference between files (https://stackoverflow.com/a/38884378/576684), but I also would like to be able to reference figures produced in one pdf in the other pdf.
Although my latex has got quite rusty with time, I imagine it could be achieved as follows:
compile the article tex and SuppMat tex a first time using rmarkdown::render()
compile these tex files from the command line in order to keep the corresponding .aux file with their references (missing references won't be resolved at this time)
recompile the 2 tex files from the command line another time where all references should now be resolved
Is it a reasonable way to do it? am I overlooking something simpler?
In any case, it requires:
a different numbering of figures in each pdf file (covered by https://stackoverflow.com/a/51337664/576684)
to prevent rmarkdown from trashing the .aux files (it seems that pandoc doesn't allow this, hence the need to create the aux file using standalone latex)
to tell latex to use the additional .aux file if it is found (probably using header-includes: in the YAML header). how can I achieve that?
Thank you very much for your help!
It turns out that the xr package is one way to go: https://texblog.org/2016/08/23/adding-references-from-an-external-file/
so this works from R:
rmarkdown::render("myarticle_ms.Rmd",
bookdown::pdf_book(base_format=rticles::plos_article),
clean=FALSE)
rmarkdown::render("myarticle_SM.Rmd",
bookdown::pdf_book(base_format=rticles::plos_article),
clean=FALSE)
tinytex::pdflatex("myarticle_ms.tex", clean=FALSE)
tinytex::pdflatex("myarticle_SM.tex", clean=FALSE)
tinytex::pdflatex("myarticle_ms.tex")
tinytex::pdflatex("myarticle_SM.tex")
with the following in the YAML header of myarticle_ms.Rmd (and the corresponding one the SuppMat file header):
header-includes:
\usepackage{xr} \externaldocument{myarticle_SM}
Hope it makes life easier for a few others :)

can you insert non-sequence related comments in a fasta file?

I was wondering if anyone knows how to add comments to a fasta file. I tried using the # character but it doesn't sit well with alignment algorithms/software.
Thanks,
What I usually found is that there are no comments. But in the wikipedia article it says that you could add comments after the > line if starting with ;. But I have never found anyone with this notation.
But I have never found any fasta file with comments. Usually the header or the name get this attribution so > E.coli can be converted to > E.coli X43 methanol as you can see here
But usually, as seen here, and here is added as a description as said.
You are not allowed to adds comment IN the sequence. But you could add a comment within an alternative format like one of the XML-based ones published by the NCBI.

get latex variable/definition from file

So we have a file which has mappings like:
one/two/one.tex 27/11/85
some/other/two.tex 27/03/89
I would like all our documents to reference this file and pull out the appropriate date. For example, for one.tex, it would display 27/11/85
Any suggestion on how I can do this?
You might try the datatool package.
You can find an entire community on the TeX StackExchange, where no TeX-related question is too small.

Odd Bibtex behaviour in a Latex document

I added a line "\cite{test}" as a test to my working Latex document. When I compiled the bibtex "!bibtex name_of_my_file, I got the expected error:
Warning--I didn't find a database entry for "test"
Then, I removed the line and compiled the bibtex again, hoping to have a working Latex file again. However, the same error occurs, even with a fresh shell. I cannot understand the behaviour. What is the logic? How can I get my Latex document working again?
[Updated Info]
The problem dissapeared as unexpectedly as it emerged. I have no idea why but it works now. Do you know the reason for the odd behaviour?
I think you are tripping over the multi-pass nature of LaTex plus Bibtex. If you look at Step 3 in this discussion, you'll see the following:
The first run (through latex)
generates an auxiliary file,
paper.aux, containing information
about citations (and other types of
references), the bibliography style
used, and the name of the bibtex
database. The second run (through
bibtex) uses the information in the
auxiliary file, along with the data
contained in the bibtex database, to
create a file paper.bbl. This file
contains a thebibliography environment
with \bibitem entries formatted
according to the bibliography style
specified.
So, what I think is happening is that your name_of_my_file.aux file still contains your placeholder \cite{test}. If you remove the auxiliary file, you should be able to start over with:
latex name_of_my_file
bibtex name_of_my_file
latex name_of_my_file
latex name_of_my_file
[Update based on additional info]: The problem was that you had a .aux file with your \cite{} still embedded. The second time that you ran latex, you overrode the old file with the new. That's why the complete set of steps includes an initial latex call, a bibtex call and two follow-up latex calls. Think of it as a multi-pass compiler and it might be more intuitive.
You could have a look at latexmk, which will take care of the fix point compilation for you.
Anyway, you should be able to build the document (pdflatex blah.tex), even if you're missing a bibliography item. The corresponding references will just appear as question marks in the PDF.
Rerun latex to regenerate the aux file.
Have a look at this discussion for pointers to a bit more information. Basically, you may have taken your citation out of the .tex file, but it still exists in one of the derived files (aux, bbl, whatever...)
Check if your bib file has the extension .bib and not .tex.
If it is .tex, just change it to .bib and that should do it.
Once I changed it accidentally to tex, by adding some references, and saving it with the "save as" option, without specifying the bib extension. That's how it can happen all of a sudden.
delete all your .aux and temporal files, re run with latex and then bibtex and then latex twice.

Resources