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

  • Home
  • SEARCH
  • 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 597133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:14:50+00:00 2026-05-13T16:14:50+00:00

using LyX I’m trying to convert the comments into marginal notes. I tried several

  • 0

using LyX I’m trying to convert the “comments” into “marginal notes”.

I tried several things but without luck.

The best shot was like this:

\makeatletter

\@ifundefined{comment}{}{%

\renewenvironment{comment}[1]%

{\begingroup\marginpar{\bgroup#1\egroup}}%

{\endgroup}}

\makeatother

or like this:

\@ifundefined{comment}{}{%

\renewenvironment{comment}%

{\marginpar{}%

{}}%

But what I get is only the first character of the text converted. Like in this image:

IMAGE MARGINAL NOTE

I searched a lot trying to find how to solve this but without luck. I found the explanation of what is happening:

Unexpected Output
Only one character is in the new font
You thought you changed font over a selection of text, but only the first character has come out in the new font.
You have most probably used a command instead of a declaration. The command should take the text as its argument. If you don’t group the text, only the first character will be passed as the argument.

What I don’t know and wasn’t able to find is how to group the text.

Hope someone could help me 🙂

Many thanks.

Best Regards,

Diego
(diegostex)

  • 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-13T16:14:50+00:00Added an answer on May 13, 2026 at 4:14 pm

    Okay, let’s walk through your (first) redefinition to see what’s happening:

    1   \@ifundefined{comment}{}{% only do this if the comment environment has been defined
    2     \renewenvironment{comment}[1]% redefining a 'comment' environment with one mandatory argument
    3     {\begingroup\marginpar{\bgroup#1\egroup}}% put the mandatory argument inside a marginpar
    4     {\endgroup}}% close the environment
    

    Here’s how LaTeX is thinking about what you’ve told it:

    \begin{comment}{xyzzy}% <-- note the mandatory argument (runs line 3)
      This is the contents of the environment.
    \end{comment}% <-- this is where LaTeX runs line 4
    

    Note that xyzzy is the mandatory argument (#1). The contents of the environment (“This is the…”) are inserted between lines 3 and 4.

    If you write the following in your document:

    \begin{comment}% <-- missing mandatory argument
      This is the contents of the environment.
    \end{comment}
    

    Then LaTeX will take the first token as the mandatory argument. In this case, the first token is T, the first character of the environment contents. So the letter T will be put in the margin and the remainder of the text will show up in a normal paragraph.

    Okay, so to achieve what we want, the comment environment doesn’t need any arguments. What we’ll do is create a box, put the contents of the environment in that box, and then place that box in the margin.

    Before we get started, if you’re including this code in the preamble of a document, you’ll need to wrap it all in \makeatletter and \makeatother since we’ll be using commands with at signs (@) in their names.

    First, let’s create a box to store the material in:

    \newsavebox{\marginbox}% contains the contents of the comment environment
    

    Next, we’ll start defining the comment environment. We’ll set the environment begin and end commands to \relax. That way our \newenvironment command will be guaranteed to work.

    \let\comment\relax% removes and previous definition of \begin{comment}
    \let\endcomment\relax% removes any previous definition of \end{comment}
    

    With that out of the way, we can define our new comment environment:

    \newenvironment{comment}{%
      \begin{lrbox}{\marginbox}% store the contents of the environment in a box named \marginbox
      \begin{minipage}{\marginparwidth}% create a box with the same width as the marginpar width
        \footnotesize% set any font or other style changes you'd like
    }{% the following lines are for the \end{comment} command
      \end{minipage}% close the minipage
      \end{lrbox}% close the box
      \marginpar{\usebox{\marginbox}}% typeset the box in the margin
    }
    

    Now, in your document, you can type:

    \begin{comment}
      This is a comment that gets printed in the margin.
    \end{comment}
    

    So just for ease of copying and pasting, here’s what a complete document would look like:

    \documentclass{article}
    
    \makeatletter
    
    \newsavebox{\marginbox}% contains the contents of the comment environment
    
    \let\comment\relax% removes and previous definition of \begin{comment}
    \let\endcomment\relax% removes any previous definition of \end{comment}
    
    \newenvironment{comment}{%
      \begin{lrbox}{\marginbox}% store the contents of the environment in a box named \marginbox
      \begin{minipage}{\marginparwidth}% create a box with the same width as the marginpar width
        \footnotesize% set any font or other style changes you'd like
    }{% the following lines are for the \end{comment} command
      \end{minipage}% close the minipage
      \end{lrbox}% close the box
      \marginpar{\usebox{\marginbox}}% typeset the box in the margin
    }
    
    \makeatother
    
    \usepackage{lipsum}% just provides some filler text
    
    \begin{document}
    
    Hello, world!
    \begin{comment}
    This is a comment that gets printed in the margin.
    \end{comment}
    \lipsum
    
    \end{document}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 412k
  • Answers 412k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to enable USB Debugging on your device. Go… May 15, 2026 at 8:00 am
  • Editorial Team
    Editorial Team added an answer Replace CGRectMake parameters with proper values. UIAlertView *alertView = [[UIAlertView… May 15, 2026 at 8:00 am
  • Editorial Team
    Editorial Team added an answer Not exactly, but take a look at the Boost String… May 15, 2026 at 8:00 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.