I use TexStudio
with a nested structure, in other words I have many files in many folders to help keep things tidy. The problem happens when I have to import another document.
\documentclass[a4paper,12pt,twoside,openright]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage[english]{babel}
\usepackage{float, newfloat}
\usepackage{svg}
\usepackage{import}
\usepackage{makecell}
\usepackage{amsmath, mathrsfs, amsfonts, amsbsy, amsthm}
\usepackage{graphicx, epstopdf}
\usepackage[lmargin=2.5cm, rmargin=2.5cm, tmargin=2.5cm, bmargin=2.5cm]{geometry}
\usepackage{setspace}
\onehalfspacing
% Definition of some commands
% FONTS
\newcommand{\definiz}[1]{\textbf{\textit{#1}}}
\newcommand{\symdef}[1]{\ensuremath{\pmb{#1}}}
\newcommand{\unit}[1]{\ensuremath{\mathrm{#1}}}
\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\important}[1]{\textit{#1}}
\newcommand{\strangeword}[1]{\textit{#1}}
% WORDS
\newtheoremstyle{mystyle}{\topsep}{\topsep}{\normalfont}{0pt}{\bfseries}{:}{0.5em}{}
\theoremstyle{mystyle}
\newtheorem*{definition}{Definition}
\newtheorem*{example}{Example}
\newtheorem*{problem}{Problem}
% MATH SYMBOL
\newcommand{\eto}{\ensuremath{\, \mathrm{e}}}
\newcommand{\tento}[1]{\ensuremath{ \times 10^{#1}}}
\newcommand{\Real}{\ensuremath{\mathbb{R}}}
\begin{document}
% Importing the title and the introduction =========================================================================
\import{./Titlepage/}{titlepage}
\ \thispagestyle{empty}
\clearpage
\import{./Titlepage/}{introduction}
\ \clearpage
% Importing the various chapters ==============================================================
\import{./Chapter 1/}{basics}
\end{document}
Usually I can make the program 'run' from imported files (by pressing F5
) but when creating a new file to import I can no longer do that. And the program gives me the error:
Missing \begin{document}. \subsection*
The program works fine if I make the script run from the main.tex file and from every other file that I've created before. What can I do?
I'll add some screenshots to explain better:
The first shows what happens when I run the program from the main file, and the second instead what happen when I run the program from the imported file.
\import
rather useinclude
command. Both should be independent from used editor (both are LaTeX commands).