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 am using a conditionalinput file inside my main file

%% Out2 doesn't exits %% Out exists

I don't want to get caption and table number at position where I don't have file.

\documentclass{article}
   \usepackage[ngerman]{babel}
\usepackage{caption}   

\makeatletter
\newcommand{\testfileexists}[1]{%
  \IfFileExists{#1}%
    {\def\inputtestedfile{\@@input #1 }}
    {\let\inputtestedfile\@empty}%
}
\makeatother


    \centering
    \testfileexists{out}
\captionof{table}{ my cation }
  \begin{tabular}{ll}
   L01&  \inputtestedfile
  \end{tabular} 


\testfileexists{out2}
\captionof{table}{ my caption}
  \begin{tabular}{ll}
    L02&  \inputtestedfile
 \end{tabular}


    \centering
\testfileexists{out}
\captionof{table}{ my caption}
  \begin{tabular}{ll}
    L03&  \inputtestedfile
  \end{tabular} 

\end{document}

%%%Contents of out.tex

\begin{tiny}\begin{tabular}{|l|C{2cm}|C{2cm}|}
\hline
&\textbf{col 1}&\textbf{col 2}\\\hline
\textbf{row 1}&1.50&1.76\\\hline
\textbf{row 2}&3.52&0.20\\\hline
\end{tabular}
\end{tiny}
share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

In this case don't use \testfileexists but use \IfFileExists{<filename>}{<yes>}{<no>} directly, i.e:

\IfFileExists{out}{%
\begin{center}
\captionof{table}{ my cation }
\begin{tabular}{ll}
 L01&  \input{out} \\
\end{tabular}
\end{center}}{}

If you use \captionof and not table it's best to wrap the whole thing in a center environment. No idea about your placement issues, though.

share|improve this answer
    
@ thanx. It works well –  user31177 Jan 3 '13 at 15:17
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.