You split post content into multiple pages with <!--nextpage-->
, so you can use $page_number = get_query_var( 'page' )
to get current page number and global variable $numpages
to get the number of pages in current post.
Displaying table of content:
global $numpages;
$post_link = get_permalink();
$page_number = get_query_var( 'page' );
$toc = [
1=>'Introduction',
'I2C Fundamentals',
'I2C on the Raspberry Pi',
'Enabling I2C on Raspberry Pi',
'I2C Transactions Using Python',
'Raspberry Pi to AVR I2C Communication'];
$post_link .= substr($post_link, -1) == "https://wordpress.stackexchange.com/" ? '' : "https://wordpress.stackexchange.com/";
$html="";
for( $i = 1; $i <= count($toc) && $i <= $numpages; ++$i) {
$highlight = ($i == $page_number) ? 'highlight' : 'nohighlight';
$html .= '<li class="' .$highlight. '"><a href="' . $post_link . $i . '">' . $toc[$i] . '</a></li>';
}