I was wondering if there was a known issue with combining threeparttable with cross references inside a float. I have my labels inside the table captions, and this works just fine unless threeparttable is called, in which case the references are ?? once it's compiled. Any suggestions would be appreciated.

ETA: Thank you scottkosty, of course I should add more detail. Here is a screenshot of one of the tables in LyX, with the threeparttable command: enter image description here

And here is the exported tex for that table, including the preamble:

%% LyX 2.0.6 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
 breaklinks=false,pdfborder={0 0 0},backref=false,colorlinks=true]


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
%% A simple dot to overcome graphicx limitations

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.



\newenvironment{proof}[1][Proof]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}

% For centered entries: 
% Allow line breaks with \\ in specialcells

% For left-aligned entries:
%% Allow line breaks with \\ in specialcells
%\begin{tabular}[#1]{@{}l@{}}#2\end{tabular}% missing % in original
%                       %%%

% *****************************************************************
% siunitx
% *****************************************************************
\newcommand{\sym}[1]{\rlap{#1}} % Thanks to Joseph Wright & David Carlisle

        group-digits            = false,
        input-symbols           = ( ) [ ] - +,
        tight-spacing       = true,
        table-align-text-post   = false,
        input-signs             = ,

% Packages for tables
\usepackage{booktabs}% Pretty tables
\usepackage{threeparttablex}% For Notes below table

% Character substitution that prints brackets and the minus symbol in text mode. Thanks to David Carlisle
  \mathcode\expandafter`\string-"8000 }

\mathcode\expandafter`\string#1"8000 }

\mathcode\expandafter`\string#1"8000 }


% *****************************************************************
% Estout related things
% *****************************************************************
\let\estinput=\input % define a new input command so that we can still flatten the document

            \textsymbols% Note the added command here

            \textsymbols% Note the added command here

% *****************************************************************
% Custom subcaptions
% *****************************************************************
% Note/Source/Text after Tables
% The new approach using threeparttables to generate notes that are the exact width of the table.
\newcommand{\Starnote}{\Figtext{* p < 0.1, ** p < 0.05, *** p < 0.01. Standard errors in parentheses.}}% Add significance note with \starnote

% To adjust margins: 





\caption{\label{tab:indices_plain}Treatment effects on index variables}


\begin{tablenotes}[flushleft] \scriptsize \item \emph{Notes:} 
OLS estimates of treatment and spillover effects. Outcome variables are listed on the left. Column (1) reports the mean of the control group for a given outcome variable. Column (2) reports the treatment effect across villages, i.e. comparing treatment households to pure control households. Column (3) reports the treatment effect within villages, i.e. comparing treatment housholds to control households in treatment villages (spillover households). Column (4) reports the spillover effect, i.e. the treatment effect on spillover households compared to pure control households. The unit of observation is the household for all outcome variables, except the psychological variables index, where it is the individual. The sample includes all households and individuals, except for the intrahousehold index, where it is restricted to co-habitating couples, and for the education index, where it is restricted to households with school-age children. For each outcome variable, we report the coefficient of interest, its standard error in parentheses, and the bootstrapped FWER $p$-value in brackets. Standard errors are clustered at the village level in columns (2) and (4), and at the household level in column (3). * denotes significance at 10 pct., ** at 5 pct., and *** at 1 pct. level.


Hopefully this helps describe the situation. I'm using LyX version 2.0.6, with the MacTeX package 2013. Thank you all!

  • Please provide a LyX Minimal Example and also export that to LaTeX and post that as well. Please also export one of those to PDF and post that so that we can easily see what you get (this might not be the same as what we get as ouput and can help when helping you). Also with LyX questions it's useful if you give your LyX version number, operating system, and TeX distribution (e.g. TeX Live). – scottkosty Jul 30 '13 at 3:12
  • Edited with the information you suggested. Thanks for the comments. – nicholson Jul 31 '13 at 17:53
  • What's in indices_plain? When I replace that line with a simple tabular, I get the caption and reference as expected. – Torbjørn T. Jul 31 '13 at 20:06
  • Thanks for the suggestion. indices_plain.tex is a tabular getting output by another program, inserted into the float as a child document. It does seem to have something to do with the problem, but unfortunately I don't think copying over tabulars is an option in this case (there are ~70 of these tables, and they get updated often). – nicholson Aug 1 '13 at 20:03
  • 2
    Sorry, I wasn't notified of your comment (add @username to make sure people are notified). Just realized that you use Include to add the tabular file: Don't. Include adds a \clearpage, try with Input instead. – Torbjørn T. Aug 3 '13 at 21:03

You have used \include to add the external file with the table, and this is not recommended -- \input should be used instead. See When should I use \input vs. \include? for details. Basically, \include should be used when the external file contains a longer part of a document (e.g. an entire chapter), that should start on a new page, whereas \input can be used for shorter pieces of code. \input is basically the same as writing the content directly in the LaTeX file.

Not exactly sure what happens when \include is used like that, but when I replace it with \input in your sample LaTeX file, the cross reference works fine.

In LyX:

Click on the box saying Include:indices_plain.tex, and change the Include Type to Input:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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