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 490483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:54:49+00:00 2026-05-13T01:54:49+00:00

How can I wrap a LaTeX command in an environment? In essence, how can

  • 0

How can I wrap a LaTeX command in an environment? In essence, how can I turn \somecommand{contents} into \begin{somecommand} contents \end{somecommand}? I have tried the obvious in creating a new environment as such:

\newenvironment{somecommand}[0]{
  \somecommand{
}
{
  }
}

but this causes problems with the curly brackets. Let me give a more concrete example. Say that you want to create the environment very-important and you want to use the command emph to accomplish this. An straightforward (but incorrect) solution would be to write something as

\newenvironment{very-important}[0]{
  \emph{
}
{
  }
}

The problem here is that the command works with the information that is found inside the environment, so it is not one of the opening commands of the environment, nor is it a closing command of the environment. The question is then: how can you do this?

  • 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-13T01:54:50+00:00Added an answer on May 13, 2026 at 1:54 am

    It seems that now I can guess what is the question.

    \newenvironment{very-important}{\startimportant}{}
    \def\startimportant#1\end{\emph{#1}\end}
    
    \begin{very-important}
    Something
    \end{very-important}
    

    This solution works well.
    But IMHO it is bad idea to wrap all text in the environment. Why?
    There are two ways to do something with the text.
    For example, you want to change the font and use italic.

    • The first method. \textit{sentence written in italics}
    • The second method. {\it sentence written in italics\/}

    What is the difference? The thing is that first method use the second one.
    \it macro changes the font and the brace } changes it back.
    \textit macro reads the full argument, changes the font and inserts the argument again:
    \textit is defined roughly as follows (not exactly).

    \def\texit#1{{\it#1\/}}
    

    The first method is always doing extra work. It reads the argument twice.
    Almost always, you can make changes and then you can everything back.

    Eventually why do you use the environment? Use macros.

    \veryimportant{
       Any thought
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a map<char*, int> labels; thats exhibiting some behavior that I can't wrap
Is there code in VBA I can wrap a function with that will let
I'd like to write a MessageConverter class that can wrap another MessageConverter. This MessageConverter
There must be an easy way to do this, but somehow I can wrap
New to WCF, but familiar with COM+ - can I wrap a WCF service
Can I use Update panel in masterpage to wrap nested pages so that when
How can I make my text wrap automatically to the next line when I
I have a LaTeX document with an image in it. There is a section,
I'm sure this is simple with the Node Relationship module but I can't wrap
If all tables I want to delete from have the column gamer_id can 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.