How to fix the warning "label `' multiply defined"

Zhiling Wang picture Zhiling Wang · Nov 24, 2014 · Viewed 8.2k times · Source

I am running an lm regression in r, where there are categorical variables and numerical variables. I am usig knitr to compile the Rnw file to make a pdf. I use texreg to make latex regression tables. But when I do the compiling, it reported that lots of lines "Label `' multiply defined". Is it a must that we should assign label to each variable in the regression? But for those factor variables, I tried to assign label, like label(data$var) <- "name", then the warning is "label" command cannot be applied to the class of factor. Now I am really confused. Can anyone help me with this?

Answer

Foad picture Foad · Nov 15, 2018

A perl-bash snippet has been developed here:

perl -nE "say $1 if /(\\label[^}]*})/" *.tex | sort | uniq -c 

which searches the .tex file for all \label{...}s using the regular expression \\label[^}]*} and then sot-group them by the number of occurance. Just fix the labels with more than 1 occurance (duplicated ones) and the warning should go away.