Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using TeXlipse, an Eclipse plugin, to create my TeX documents. To structure my files I use \input{filename}. Now the problem is, that every file is one section or subsection. TeXlipse shows me a warning "Subsection has no preceding section" at the beginning of every file in the Eclipse window. How can I avoid this warning? This is not really a problem, because if a file contains only a subsection and is included by \input{} into another file, where the section is located, there IS a preceding section. I'd like to avoid this warning to use it for other things like overfull hboxes.

The warning is displayed in Eclipse as shown in the figure: enter image description here

Here is a MWE:

main.tex

\documentclass{scrbook}
\begin{document}
\chapter{Foo}
\section{Foo2}
\input{test}
\end{document}

test.tex

\subsection{Foo3}

In the file test.tex I get the warning described above.

share|improve this question
    
Your title mentions "warnings" while your discussion mentions "errors", or "not really an error". Which is it? –  Werner Oct 27 '11 at 18:16
    
It is always best to compose a MWE that illustrates the problem including the \documentclass so that those trying to help don't have to recreate it. –  Peter Grill Oct 27 '11 at 18:16
    
@Werner corrected my question... –  strauberry Oct 27 '11 at 18:17
1  
I tried your MWE with TeXLive2011 and did not receive any warnings. –  Peter Grill Oct 27 '11 at 18:56
1  
@cmhughes Updated my question. It is not the compile process but the eclipse IDE with the Eclipse plugin Texlipse –  strauberry Oct 28 '11 at 6:59
show 4 more comments

2 Answers 2

From the screen shot, it appears as if the warning is displayed when you have a subfile open, not when compiling the main file. So, looking at this file alone, which is itself not compilable, there is a \subsection without a parent \section. As I mentioned in the comments, the following:

test.tex:

\documentclass{article}
\begin{document}
\subsection{foo}
    %...other content of this subsection...
\end{document}

does not result in a warning when compiled. So, perhaps one way of dealing with this is to have a fully compilable sub-file (as shown above) by adding \documentclass and \begin{document} prior to the content followed by \end{document}. This should eliminate the warning. In the main file, you would need to include the standalone package:

main.tex:

\documentclass{scrbook}
\usepackage{standalone}
\begin{document}
\chapter{Foo}
\section{Foo2}
\input{test}% import the subsection
\end{document}

Martin, the package author provides a good example here. Also, do note that the main.tex file will need to include all the packages required by the subfiles.

If you include all the packages in the subfiles as well, you will be able to compile each them separately as well.


Update: However, quoting from the TeXlipse documentation it appears that this particular issue is hard coded into its own syntax parser:

The plug-in tries to indicate if there are errors in the document... Also, subsections without a preceding section (or subsubsection without a preceding subsection) cause a warning annotation (the warning annotation is a yellow triangle with a black exclamation mark).

so one way to get around this would be to tell the parser to ignore this portion of your document by surrounding it with %### as per the TeXlipse FAQ:

%###
\subsection
%###
share|improve this answer
add comment

I created a project structure that circumvents this warning. For my articles, I have separate self containing sub-projects for the (sub)sections. It does not require any customized build files or the like, and somewhat enforces a separation of concern (common images, bib, style file ...). You can check it out, it is available here.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.