开发者

Labels in xtable captions for crossreferencing in lyx

I am using pgfsweave with Lyx 1.6.8 and xtable. providing table captions by

<<result=tex>>=
print(xtable(<dataframe>,caption="Here is my caption"))
@.

How can I insert a label into the table caption 开发者_如何学运维that I can crossreference in the text from the lyx>Insert>Cross-reference menu?

I have tried to insert>float>table and inserted print(xtable(<dataframe>,floating=FALSE)) and "Here is my caption" in the Table caption inner frame but this results in (literally):

[float Table:
<...Table ...>
[Table 2: "Here is my caption" ] ]

Even a barefoot workaround to crossreference

<<result=tex>>=
print(xtable(<dataframe>,caption="Here is my caption",label = "tab:one"))
@

from an ERT-box would help.


SOLVED: Just use TWO arguments in the xtable-function call in the R-code:

xtable(<dataframe>
, caption = "My caption\\label{tab:MyTable1}"
,label="tab:MyTable1")

The \\label{tab:MyTable1} inside the caption is changed to \label{tab:MyTable1} by R and then interpreted by LaTeX.

The argument label="tab:MyTable1" is ignored by R and therefore at your disposal to trick Lyx into allowing for crossreferencing to the label table label. Use Insert>label to insert the label "tab:MyTable1" (excluding the quotes) here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜