Is it possible to use the LaTeX packages "subfiles" and "background"? - background

I ran into a problem using the packages "subfiles" and "background" in my LaTeX project.
I have a main file that looks like this:
\documentclass[10pt, a4paper, parskip]{scrartcl}
\usepackage[pages=some, angle=0, opacity=1, scale=1]{background}
\usepackage{subfiles}
\definecolor{background}{RGB}{204, 68, 68}
\begin{document}
\subfile{subfile1}
\subfile{subfile2}
\end{document}
I want to include two subfiles. The first subfile looks like this:
\documentclass[main.tex]{subfiles}
\begin{document}
\backgroundsetup{
contents={
\begin{tikzpicture}[overlay]
\path [fill=background] (-.5\paperwidth, 6) rectangle (.5\paperwidth, 9.25);
\end{tikzpicture}
}
}
\BgThispage
Text...
\end{document}
The second subfile looks similar but has a different background setting:
\documentclass[main.tex]{subfiles}
\begin{document}
\backgroundsetup{
contents={
\begin{tikzpicture}[overlay]
\path [fill=background] (-.5\paperwidth, -12.5) rectangle (.5\paperwidth, 12.5);
\end{tikzpicture}
}
}
\BgThispage
Text...
\end{document}
Compiling the two subfiles as standalone files gives me the expected result. But compiling the main file does not set the backgrounds right, even the file compiles without errors.
Is it possible to fix this error or are there working alternatives for the packages "subfiles" or "background" that work together?
EDIT: I changed the main file to this:
...
\begin{document}
\subfile{subfile1}
\newpage
\subfile{subfile2}
\end{document}
...
Now I only see the watermark saying "draft" when compiling the main file, but it is set to the correct pages.
EDIT: I figured out that the watermark appears if the included subfile is just one page long. If the content is at least two pages long the background is displayed correctly. Does anyone know why?

I found a way to solve the issue. In the main file delete the \newpage command and in every subfile end the code with a \newpage command. This way the compilation of the main file and of all subfiles as standalone files works correctly.
Here is the comment that told me so.

Related

Error in creating PDF in Latex in Texstudio

I want to create presentation in latex. Following is the code :
\documentclass{beamer}
\usetheme{default}
\title{Electrical Machines}
\subtitle{Electromechanical Energy Conversion}
\author{Vivek kumar Pal}
\institute{Department of Electrical Engineering\\VJTI}
\date{\today}
\subject{Electricals}
\begin{document}
\end{document}
Code is getting executed properly. But following error is coming for creating pdf :
does not look like a valid PDF document. Either the file is corrupt or it is in the process of creation. Retrying every two seconds.
Kindly help in this and let know the reason.
You are missing content. Once you add it it will work properly.
\documentclass{beamer}
\usetheme{default}
\title{Electrical Machines}
\subtitle{Electromechanical Energy Conversion}
\author{Vivek kumar Pal}
\institute{Department of Electrical Engineering\\VJTI}
\date{\today}
\subject{Electricals}
\begin{document}
Enter content here.
\end{document}
`

Using a list in a text file as a list in Latex \foreach loop

Sorry if I didn't tag\classify this well. But here is my problem
I have a list generated by another program which goes into a text file, when I want to simply include this text in my latex document i use \input{writing.txt} this works fine.
The issue i'm having is figuring out a way to use a text file that has a list like
picnname1 picname2 picname2 ... and have latex recognize that as my list, included in \input{list.txt}
Below is a broken example, which works when I replace \input{list.txt} with the actual list. My attempts so far have gotten me nowhere. So any help would be greatly appreciated.
\documentclass{article}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{python}
\usepackage{graphicx}
\usepackage[space]{grffile}
\usepackage[latin1]{inputenc}
\usepackage[top=2cm]{geometry}
\foreach \picname in {\input{list.txt}}
{
\section{\MakeUppercase\picname}
\begin{figure}[h]
\centering
\includegraphics[width=10cm]{\picname_Main.pdf}
\caption{This depicts the trend in \picname}
\end{figure}
\input{"filepathforsometext"\picname.txt}
\input{"filepathforatable"\picname_GrowthTable}
\input{"filepathforanothertable"\picname_ActualPop}
\clearpage
}
\end{document}

Importing *.pdf_tex file error

I have made a graphic with inkscape. Now I'm trying to build it in Latex. I' m working with TEXMaker. Therefore I have exported my graphic as *.pdf_tex and *.pdf.
In macros i have added the following
\usepackage{color}
\usepackage{transparent}
\graphicspath{{fileWithPictures/}}
my picture is build in like this:
\begin{figure}
\centering
\def\svgwidth{175pt}
\input{fileWithPictures/pic.pdf_tex}
%\includegraphics[width=2in]{fileWithPictures/pic.pdf_tex}
\end{figure}
Here I'm getting the following error. "!Package pdftex.def Error: File'pic.pdf" not found. See the pdftex.def package.."
I have tryed also to work with includegraphics which not succed. Because there he it doesn't recognize pdf_tex format.
Interesting is that the compiler says that there is not a file called "pic.pdf" and not "pic.pdf_tex". Althought both files are clearly in the file. To be sure i put the pic.svg file in the file. Now i have no more ideas and would be happy to get some help
Thanks
Use resizebox to set the width of your file instead of \def\svgwidth{175pt} it will solve your problem
\resizebox{\textwidth}{!}{
\input{fileWithPictures/pic.pdf_tex}
}

Knitr + Beamer to PDF: Incorrect Font Symbols

I'm using TexStudio 2.8.4 to create a pdf containing knitr output and I'm running into issues with symbols showing up incorrectly either in the pdf or when copy and pasted from the pdf. Here's a minimal working example.
\documentclass{beamer}
\begin{document}
\begin{frame}[fragile]
<<>>=
#dollar$sign
if(2+2 == 4){print("math")}
#
\end{frame}
\end{document}
In my pdf output, the $ in the commented out font shows up as the pound (currency) sign, but when copy and pasted shows up correctly as a dollar sign. This does not occur when it is not commented out.
More problematically, while the braces {} appear correct in the pdf output, when copied and pasted they are f and g. This confusion does not affect R's interpretation of the braces, however.
Do you have any thoughts/suggestions for fixing this? As a work around, I'm just using a non-echoed knitr block and using a latex verbatim environment for the code on the front side, though this is not ideal.
The command I'm using in my custom build is:
"C:/Program Files/R/R-3.2.2/bin/Rscript.exe" -e "library(knitr); knit2pdf('%.Rnw')" | pdflatex -synctex=1 -interaction=nonstopmode %.tex | "C:/Program Files (x86)/Adobe/Reader 11.0/Reader/AcroRd32.exe" "?am.pdf"
Cheers!
This seems to be a problem with LaTeX encoding. The solution is adding \usepackage[T1]{fontenc} to your preamble as suggested here.

How can I change the margins on a PDF document created by Doxygen?

I am using doxygen to generate a PDF of my code documentation. The PDF has very big margins when using PAPER_TYPE = letter. It looks OK when using a4wide but I would like to have more control over it. I want to use a package called geometry but can't figure out where to add code like this:
\usepackage[top=2.9cm,left=2in,bottom=1in,right=1in]{geometry}
I would like to not have to change the doxygen-generated tex files if possible.
In your Doxyfile, add or edit the EXTRA_PACKAGES line:
EXTRA_PACKAGES = mydoxy
Then create a new file called mydoxy.sty:
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{mydoxy}[2009/12/29 v1.0.0 csmithmaui's Doxygen style]
\RequirePackage[top=2.9cm,left=2in,bottom=1in,right=1in]{geometry}
% any other custom stuff can go here
\endinput
Drop that mydoxy.sty where LaTeX can find it.
The EXTRA_PACKAGES line will tell Doxygen to add \usepackage{mydoxy} to the preamble of the .tex files it generates. This will cause LaTeX to look for a file named mydoxy.sty. In the mydoxy.sty file that we've created, we can add whatever LaTeX code we like (before the \endinput line). Feel free to drop any other customizations you like in this style file.
Note that I haven't tested this, and I'm making a number of assumptions that may be false. But it should at least get you started.