1

I have a large LaTeX project (my thesis) with a main TeX file (main.tex) and many subfiles contained in their own sub-directory. All are interrelated with the subfiles package.

Now I want to add a title page to appear on the first page of the compiled pdf file, with hebrew text: To include the thesis title, author name and institution name.

The preponderance of the project is best compiled with pdfLatex, and therefore I wish to stick with this one and not change to XeLaTeX.

I successfully compiled a .tex file that contains hebrew AND english letters (titlepage.tex).

I want titlepage.tex to appear first, and after it all the series of chapter0*.tex files.

Now comes the question - how to compile the project properly?

I tried to import the standalone and import packages to main.tex:

\usepackage[subpreambles=true]{standalone}
\usepackage{import}

and then call for titlepage.tex right after \begin{document}: \usepackage[subpreambles=true]{standalone} \usepackage{import} \begin{docment} \import{./}{titlepage} \end{document}

But nothing compiled - a multitude of errors concerning the standalone.sty file.

Any help?

The hierarchical file structure is as follows:

root folder
├main.tex
├titlepage.tex
└───figures
| │ figure01
│ │ figure02
│ │ figure03
└───subfiles
| │ chapter01
| │ chapter02
| │ chapter03

The main.tex file structure:

\documentclass{tufte-book} % Tufte-book format
\usepackage[utf8]{inputenc} 
\usepackage[english]{babel} % Bibliography
\usepackage{biblatex}
\addbibresource{references.bib}
\usepackage{subfiles} % Best loaded last in the preamble
%%% Document %%%
\begin{document}
\chapter{Chapter 1}
\subfile{subfiles/chapter01}

\chapter{Chapter 2}
\subfile{subfiles/chapter02}

\chapter{Chapter 3}
\subfile{subfiles/chapter03}
\end{document}

The chpater0*.tex files has just the same document preamble as main.tex.

The Hebrew language file, to be used as a title page:

\documentclass{article}
%\usepackage[subpreambles=true]{standalone}
%\usepackage{import}
\usepackage[utf8x]{inputenc} % utf8x for hebrew letters
\usepackage[english,hebrew]{babel}
\selectlanguage{hebrew}

\begin{document}
כיתוב בעברית.
\selectlanguage{english}
English text.
\end{document}

Note: I compile the the project in overleaf.

1
  • 1
    In titlepage.tex I'd remove everything up to and including \begin{document} as well as \end{document}, and include the file from main.tex using \input{titlepage}. No standalone and import needed (any packages and definitions that are needed in the title page, put them into the preamble). There is probably no need to compile the titlepage separately. If there is, then use \subfile to load the titlepage.
    – gernot
    Mar 12, 2021 at 22:12

1 Answer 1

1

I am using Overleaf also with multiple subfiles. I use the command \documentclass[main.tex]{subfiles} to import the preamble of the main into the subfiles. Besides \selectlanguage should be used inside the document I think.

Here is my an example inspired by your MWE that worked for me :

main.tex :

\documentclass{tufte-book} % Tufte-book format
\usepackage[utf8x]{inputenc}
\usepackage[main=english, hebrew]{babel}
\usepackage{subfiles} % Best loaded last in the preamble

\newcommand{\onlyinsubfile}[1]{#1}
\newcommand{\notinsubfile}[1]{}

%%% Document %%%
\begin{document}

\renewcommand{\onlyinsubfile}[1]{}
\renewcommand{\notinsubfile}[1]{#1}

\subfile{titlepage}
\chapter{Chapter 1}
\subfile{subfiles/chapter0}

\end{document}

titlepage.tex

\documentclass[main.tex]{subfiles}

\begin{document}
\selectlanguage{hebrew}
כיתוב בעברית.
\selectlanguage{english}
English text.
\end{document}

The functions \onlyinsubfile and \notinsubfile can be used in the subfiles and allow you to execute commands depending if you are trying to compile the standalone subfile or the whole document.

Finally for managing biblatex with hebrew caracter look at this answer Using Biblatex with utf8x

3
  • Thanks a lot for your help! But, I now notice that there is a problem with the figure environment: I get the following errors: Missing \endcsname inserted; Use of \m@^_ doesn't match its definition; Extra \endcsname. Do you have any idea why?
    – tush
    Mar 16, 2021 at 15:51
  • I am not sure how this could be related to the use of subfiles... Could you post a MWE ? Maybe in another question and post the link in comment. I will have a look
    – nlair
    Mar 16, 2021 at 18:38
  • Good idea. The new answer I posted can be found here.
    – tush
    Mar 16, 2021 at 19:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .