1

i have a portion of code in minted package:

\begin{minted}[
 frame=single,
 numbersep = 1pt,
 breaklines=true,
 framesep=1mm,
 baselinestretch=1,
 bgcolor=LightGray,
 fontsize=\footnotesize,
 linenos
 ]{java} 
 package test.multiple_interactions;
 public class MainActivity extends Activity
 {static{System.loadLibrary("threadLeak"); //"libthreadLeak.so"}
 public static native void send(String data);
 protected void onCreate(Bundle savedInstanceState){
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 TelephonyManager tel = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
 String imei = tel.getDeviceId();//source
 String[] arr = new String[10];
 arr[1] = imei;
 send(arr);}}
 \end{minted}

I want to reset line numbers in middle of my code and start it from 1 again. is that possible in minted package? enter image description here

0

Main changes based on your (incomplete) example:

  • option escapeinside=|| is added to minted environment
  • code snippet |\setcounter{FancyVerbLine}{1}| is appended after java code line protected void onCreate(Bundle savedInstanceState){. Here FancyVerbLine is the counter used in line numbering.

Note: This may break other line-number minted options.

\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{minted}

\begin{document}
\begin{minted}[
    frame=single,
    numbersep = 1pt,
    breaklines=true,
    framesep=1mm,
    baselinestretch=1,
    bgcolor=LightGray,
    fontsize=\footnotesize,
    linenos,
    escapeinside=||
  ]{java} 
  package test.multiple_interactions;
  public class MainActivity extends Activity
      {static{System.loadLibrary("threadLeak"); //"libthreadLeak.so"}
  public static native void send(String data);
  protected void onCreate(Bundle savedInstanceState){|\setcounter{FancyVerbLine}{1}|
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    TelephonyManager tel = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    String imei = tel.getDeviceId();//source
    String[] arr = new String[10];
    arr[1] = imei;
    send(arr);}}
\end{minted}
\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.