-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
demo of new feature: alternate line color #8
Comments
Here are some simple examples: \documentclass{article}
\usepackage{fvextra}
\usepackage[x11names]{xcolor}
\fvset{
highlightcolor={LightBlue1!50, LightBlue1!30},
highlightlinenumbercolor={yellow!50, yellow!30},
numbersep=5pt
}
\begin{document}
\begin{Verbatim}[linenos, numbers=right, breaklines=true]
\def\FV@HighlightLine#1{%
\@tempcnta=\c@FancyVerbLine
\@tempcntb=\c@FancyVerbLine
\ifcsname FV@HighlightLine:\number\@tempcnta\endcsname %\@tempcnta\endcsname
\advance\@tempcntb\m@ne % some some some some some some some comments
\ifcsname FV@HighlightLine:\number\@tempcntb\endcsname
\advance\@tempcntb\tw@
\end{Verbatim}
\bigskip
\begin{Verbatim}[linenos, numbers=left, breaklines=false]
\def\FV@HighlightLine#1{%
\@tempcnta=\c@FancyVerbLine
\@tempcntb=\c@FancyVerbLine
\ifcsname FV@HighlightLine:\number\@tempcnta\endcsname
\advance\@tempcntb\m@ne
\ifcsname FV@HighlightLine:\number\@tempcntb\endcsname
\advance\@tempcntb\tw@
\end{Verbatim}
\bigskip
\begin{Verbatim}[linenos, numbers=both, breaklines=false, frame=single]
\def\FV@HighlightLine#1{%
\@tempcnta=\c@FancyVerbLine
\@tempcntb=\c@FancyVerbLine
\ifcsname FV@HighlightLine:\number\@tempcnta\endcsname
\advance\@tempcntb\m@ne
\ifcsname FV@HighlightLine:\number\@tempcntb\endcsname
\advance\@tempcntb\tw@
\end{Verbatim}
\end{document} |
This looks like a very nice feature and I'll be happy to include it. I will need to think a little about the best way to do some things. Your |
Thanks so much for your response. Before you getting back, if I get new ideas related to this feature, I will post them here as well. |
The purpose of this feature is to let odd- and even lines have different highlight colors. I have committed a demo implementation to my forked repo. Only sty file is changed in that commit.
Some Explanations
highlightcolor
can be used ashighlightcolor = SingleColor | {<OddLineColor>, <EvenLineColor>}
.highlightlinenumbercolor
changes the highlight color of line number, and this option can be used the same ashighlightcolor
.\arabic{FancyVerbLine}
) is hard, a new optionlinenumberwidth=<dimen>
is defined.breaklines=true
, the total heigh of a line is not determined until\FV@SaveLineBox
. Therefore\FV@LeftListNumber
(with its background) is typeset after\FancyVerbFormatLine
.Shortcut:
\def\FV@LineNumberBackground{}
is a compromise since\def\FV@LineNumberBackground\@empty
and\def\FV@LineNumberBackground\relax
both raise error. I guess it is a problem of order of macro expanding.\pickTwo
macro may have nicer implementation.I am not fully understood about packages
fancyvrb
andfvextra
, so any suggestions are helpful. And, more test is needed of course.The text was updated successfully, but these errors were encountered: