Re: Convert "Comment" into "Marginal Note"

2010-02-16 Thread Daniel Lohmann

Hi Diego,

I did something similar for "lyxgreyedout" in my dissertation. The  
caveat is that both., "lyxgreyedout" and "comment" are environments,  
whereas marginpar is a command. So actually you are looking for a  
technique to grab the content of an environment in a way it can be  
passed to a command.


After hours of googling I had found the trick. The amsmath package  
provides  a fairly magic macro called \coll...@body to perform this  
task.


I have added the respective lines from my thesis preamble. I developed  
three variants to typeset the comments, but don't know if the  
marginpar variant ever really worked. The tikz variant was way  
cooler :-)



Have fun,

Daniel

%*
%** handling of notes  

% LyX typesets "greyed out" notes in an LaTeX environment  
"lyxgreyedout". By

% redefinition of this environment, we can control how notes are printed
% out in the PDF.
%
% The \coll...@body (provided by amsmath) trick was taken from
% 
http://groups.google.com/group/comp.text.tex/browse_thread/thread/4cc1379654f40925/2316a38e9912fe23?lnk=st&q=+%5Ccollect%40body+1995+&rnum=1#2316a38e9912fe23
% Basically, it can be used to pass all content of an enviroment to a  
command.


%%   % Variant 1: typeset notes as \marginpar (yet to be completed)
%%  \makeatletter
%%  \renewenvironment{lyxgreyedout}{\coll...@body\@NOTE}{\global 
\...@ignoretrue}

%%  \newcomma...@note[1]{\marginpar{#1}}
%%  \makeatother
%%  \addtolength{\textwidth}{-5cm}



%%  % Variant 2: typeset notes as footnotes. We use the bigfoot package
%%  % to define our own footnote stack for the notes
%%
%%
%%  % The following replaces the default \footnote command by an own
%%  % to ensure that ordinary footnotes are always printed first
%%  \DeclareNewFootnote{A}
%%  \renewcommand{\footnote}{\footnoteA}
%%
%%  % This defines the \footnoteNOTE command for the extra stack.
%%  % "greyed out" are printed as sans-serif, red colored footnotes
%%  % with captial arabic numbering
%%  \DeclareNewFootnote[para]{NOTE}[Alph]
%%  \renewcommand{\footnoteNOTE}{%
%%\stepcounter{footnoteNOTE}%
%%\textcolor{red}{\Footnotemark\thefootnoteNOTE} \FootnotetextNOTE 
\thefootnoteNOTE}

%%
%%  % redefine the lyxgreyedout environment
%%  \makeatletter
%%  \makeenvironment{lyxgreyedout}{\coll...@body\@NOTE}{\global 
\...@ignoretrue}
%%  \newcomma...@note[1]{\footnotenote{\begin{minipage}[t]{\textwidth} 
{\scriptsize\sffamily{\textcolor{red}{#1}}}\end{minipage}}}

%%  \makeatother

%%   % Variant 3: typset notes with tikz as marginpars
   \usepackage{tikz}
%%   \makeatletter
%%   \makeenvironment{lyxgreyedout}{\coll...@body\todonote}{\global 
\...@ignoretrue}%

%%   \makeatother
%%
%%   \newcommand{\todoNOTE}[1]{%
%% \begin{tikzpicture}[remember picture, baseline=-0.75ex]%
%%   \node [coordinate] (inText) {};%
%% \end{tikzpicture}%
%% \marginpar{%
%%   \begin{sffamily}%
%%   \begin{scriptsize}%
%%   \begin{tikzpicture}[remember picture]%
%% %  \draw node[draw=Orange_4, fill=Orange_4!50, text width =  
3.4cm ] (inNote)
%%   \draw node[draw=Gray_40, fill=Gray_10, text width =  
3.4cm ] (inNote)

%%   {#1};
%%   \end{tikzpicture}%
%%   \end{scriptsize}%
%%   \end{sffamily}%
%% }%
%% \begin{tikzpicture}[remember picture, overlay]%
%%   \draw[draw = Gray_40, thick]
%% %  \draw[draw = Orange_4, thick]
%%   ([yshift=-0.2cm] inText)
%% -| ([xshift=-0.2cm] inNote.west)
%% -| (inNote.west);
%% \end{tikzpicture}%
%%   }%

  % Variant 4: ignore them at all -- for the final print
  \makeenvironment{lyxgreyedout}{}{}


On 13.02.2010, at 19:51, Diego wrote:

Hi, 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 the attached image.


I searched a lot trying to find how to solve this but without luck.  
I found the explanation of what is happening here:http://theoval.cmp.uea.ac.uk/~nlct/latex/csed/solutions/fonts.html


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,
Die

Convert "Comment" into "Marginal Note"

2010-02-13 Thread Diego
  
Hi, 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 the 
attached image.
 
I searched a lot trying to find how to solve this but without luck. I found the 
explanation of what is happening here: 
http://theoval.cmp.uea.ac.uk/~nlct/latex/csed/solutions/fonts.html 
 
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)<>