Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4609566
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:00:21+00:00 2026-05-22T01:00:21+00:00

Apologies for the very basic question! I just want to read in a latex

  • 0

Apologies for the very basic question!

I just want to read in a latex file (so text basically) and output all the (say) theorems, which are always in the format

\begin{theorem}
some lines of latex
\end{theorem}

I always kind of figured Perl was the right language for this!

Of course, I only know very basic programming in C++ and Java, and virtually no Perl.

Nonetheless I can currently read in a text file, and process it line by line.

It seems the most basic way to do this is:

($string =~ /pattern/) 

I started getting confused by then reading about control codes like ?,*+,$, etc.

Any simple references or links to get me started?

(I put this on here and not the Tex site, as it could be useful generally for reading text files, and not just LaTeX!)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:00:22+00:00Added an answer on May 22, 2026 at 1:00 am

    If you’re on a Unix-y machine (this includes Macs), for a task this small you should reach for sed first:

    $ sed -ne '/^\\begin{theorem}$/,/^\\end{theorem}$/p' doc.tex
    

    If you’re on Windows, though, you don’t get sed bundled with the OS, and perl is rather easier to install AIUI, so here’s the equivalent:

    > perl -ne 'print if /^\\begin\{theorem\}$/.../^\\end\{theorem\}$/;' doc.tex
    

    You may notice a distinct resemblance between these two commands. That’s not an accident; Perl took ideas from many of the older Unix text-munging utilities, sed included.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies if this is a very basic question, but I am preparing to create
Apologies for the very broadly title question. Basically this follows on from my earlier
First of all, I would like to apologise if my question is very basic
Apologies for the very basic question - crash course in javascript coming up! But
Apologies for asking what's probably a very obvious question, I've been banging my head
I have a very novice question, so apologies if the answer to this is
Apologies if this is a dumb question, i'm very new to working in 3D.
I realise that this must be a very basic question, but my google-fu seems
Disclaimer : This is a very basic question, but keep in mind I come
I apologize because I am quite certain this is a basic question. All I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.