\documentclass[10pt,reqno]{amsart} \usepackage{amsmath,amssymb,amsthm} \usepackage{catchfilebetweentags} \section{Test with my patch counts to say 11} \label{sec:test-with-my} But if I close the file after 10 and reopen it it incorrectly inserts the tag 10 not 11 %<*test-catch:1> 1 % %<*test-catch:2> 2 % %<*test-catch:3> 3 % %<*test-catch:4> 4 % %<*test-catch:5> 5 % %<*test-catch:6> 6 % %<*test-catch:7> 7 % %<*test-catch:8> 8 % %<*test-catch:9> 9 % %<*test-catch:10> 10 % \section{Test without my patch till 10} \label{sec:test-without-my} %<*1> 1 % %<*2> 2 % %<*3> 3 % %<*4> 4 % %<*5> 5 % %<*6> 6 % %<*7> 7 % %<*8> 8 % %<*9> 9 % %<*10> 10 % %<*11> 11 % \end{document}