The number shown in the error message always refer to the line number in the file currently being read in, so there's no offset to compute.
Therefore, if a message such as
l.1041 \end{frame}
appears, it refers to the line number in the last file appearing in the log after an open parentheses (
, in your case, probably
(./my_headers.tex
will be in the log some lines before the error message. If you launch the typesetting engine with the -file-line-error
option, you'll get more informative messages, for example
./my_headers.tex:13: Undefined control sequence
l.13 \wronglytypedcommand
The call should thus be
pdflatex -file-line-error <other options> main
where <other options>
may contain the usual options such as -synctex=1
. How to add this option depends on the way the typesetting is launched from the front-end or editor.
Best Answer
The way to find the error is to provide a minimal working example:
reduce your document, by commenting out parts, to a minimal complete version producing the error
It is quite possible that in this process you find the cause of the error for yourself.