-1

I would like to go through this file:

\chapter{CHAPTER}

TEXT   
\e
h454
\e    
\e
454
\e    
\begin{figure}
\NOTE{figure}
\centering
\includegraphics[width=0.49\textwidth]{f.pdf}
\caption{\NOTEB{The concept}}
\label{fig}
\end{figure}

SOME TEXT    
\e
454
\e    
SOME TEXT

\begin{figure}
\NOTE{figure}
\centering
\includegraphics[width=0.49\textwidth]{f.pdf}
\caption{\NOTEB{The concept}}
\label{fig}
\end{figure}

\chapter{CHAPTER}

SOME TEXT

and print some parts:

awk '/\\begin\{figure\}/,/\\end\{figure\}/' file.tex
awk '/\\e/,/\\e/' file.tex
awk '/\chapter/' file.tex

but all into one file and in the order as in the input file. So, the desired output is (empty line does't matter):

\chapter{CHAPTER}  
\e
h454
\e
\e
454
\e
\begin{figure}
\NOTE{figure}
\centering
\includegraphics[width=0.49\textwidth]{f.pdf}
\caption{\NOTEB{The concept}}
\label{fig}
\end{figure}    
\e
454
\e    
\begin{figure}
\NOTE{figure}
\centering
\includegraphics[width=0.49\textwidth]{f.pdf}
\caption{\NOTEB{The concept}}
\label{fig}
\end{figure}
\chapter{CHAPTER}

How to connect these commands and make it to follow the order of input file?

Archie
  • 93
  • 2
  • 9

1 Answers1

1

Could you please try following.

awk '
/\\label/{
  next
}
/\\begin\{figure\}|\\beq/{
  found=1
}
found;
/\\end\{figure\}|\\eeq/{
  found=""
}
/chapter/
' Input_file

Since I have written this on my cell I haven't tested it, please feel free to comment on any suggestions.

RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
  • How to remove lines starting \label from the file? I tried to write in the end: `| '!/^\\label/'` (I mean that I edit your last line as `'| '!/^\\label/' Input_file`) – Archie Oct 31 '19 at 20:46
  • 1
    @Archie, please try my edit now and lemme know if this helps? – RavinderSingh13 Nov 01 '19 at 02:02