%20%E3%81%A7%E5%A7%8B%E3%81%BE%E3%82%8B%E6%96%87%E5%AD%97%E5%88%97%E3%82%92%E8%87%AA%E5%8B%95%E7%9A%84%E3%81%AB%E8%89%B2%E5%88%86%E3%81%91%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%82%88%E3%81%84%E3%81%A7%E3%81%99%E3%81%8B%3F.png)
クラスを使用して、メインテキストでも脚注でも、文字memoir
で始まる文字列に自動的に色を付ける方法を探しています。これを行う方法をご存知ですか?@
更新: 私も bibtex を使用していますが、引用にリンク ボックスや色を付けたくないので、hidelink オプションを使用します。
簡単な例を挙げます:
\documentclass[a4paper, 12pt,twoside, openright]{memoir}
\usepackage{polyglossia}
\setdefaultlanguage{french}
\usepackage{fontspec}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[autostyle=true,french=guillemets,maxlevel=3]{csquotes}
\usepackage{xparse}
\usepackage{graphicx}
\usepackage[protrusion=true]{microtype}
\makeatletter
\renewcommand\@makefnmark{\hbox{\@textsuperscript{\normalfont\color{BurntOrange}\@thefnmark}}}
\renewcommand\@makefntext[1]{%
\parindent 1em\noindent
\hb@[email protected]{%
\hss\@textsuperscript{\normalfont\@thefnmark}}#1}
\makeatother
\usepackage[hidelinks, pdfusetitle]{hyperref} % Creates hyperlinks and index in the PDF document, preferably load after biblatex
\begin{document}
\chapterstyle{bringhurst}
This is a link in a footnote \footnote{My link is \href{http://www.google.fr}{@google}}
This is a colored link in my text \href{http://www.google.fr}{@google}
This is a normal link \href{http://www.google.fr}{google}
\end{document}
すべてのリンクではなく、@ で始まるテキスト リンクを自動検出して色付けしたいと思います。
答え1
特定の記号 で始まるすべての単語を色付けする問題に対する一般的な解決策を備えた改訂版。@
孤立文字の状況を処理するために再編集されました。をアクティブにし、赤をオンにして の保存されたコピーを印刷するように定義すること@
で実行されます。 この改訂の鍵となるのは、再帰を使用して次の単語 (まだ赤) を出力するマクロです。 スペースに遭遇すると、黒に戻ります。 グループの終わりに遭遇すると、終了します (また、黒に戻ります)。@
@
\tilblank
\documentclass{article}
\usepackage{ifnextok}
\usepackage{xcolor}
\makeatletter
\def\tilblank#1{#1\IfNextToken\@sptoken{ \color{black}}{%
\IfNextToken\egroup{}{\tilblank}}}
\def\atend{\IfNextToken\@sptoken{ \color{black}}\tilblank}
\let\svat @
\makeatother
\catcode`@=\active
\def@{\color{red}\svat\atend}
\begin{document}
This tests @the use of @midstream or in its own {@group}.
Also testing @ by itself and at the end of a @paragraph.
This follows in black, as @it should.
\end{document}
オリジナルのソリューション
このアプローチによって他に何かが壊れるかどうかはわかりません。 を@
アクティブにします。また、これは@
単語が独自のグループにある場合にのみ機能します。つまり、@
テキストで を使用する場合は、 で囲む必要があります{}
。
\documentclass[a4paper, 12pt,twoside, openright]{memoir}
\usepackage{polyglossia}
\setdefaultlanguage{french}
\usepackage{fontspec}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[autostyle=true,french=guillemets,maxlevel=3]{csquotes}
\usepackage{xparse}
\usepackage{graphicx}
\usepackage[protrusion=true]{microtype}
\makeatletter
\renewcommand\@makefnmark{\hbox{\@textsuperscript{\normalfont\color{BurntOrange}\@thefnmark}}}
\renewcommand\@makefntext[1]{%
\parindent 1em\noindent
\hb@[email protected]{%
\hss\@textsuperscript{\normalfont\@thefnmark}}#1}
\makeatother
\usepackage[hidelinks, pdfusetitle]{hyperref} % Creates hyperlinks and index in the PDF document, preferably load after biblatex
\begin{document}
\let\svat @
\catcode`@=\active
\def@{\color{red}\svat}
\chapterstyle{bringhurst}
This is a link in a footnote \footnote{My link is \href{http://www.google.fr}{@google} checking revert}
This is a colored link in my text \href{http://www.google.fr}{@google}
This is a normal link \href{http://www.google.fr}{google}
\end{document}
\documentclass{article}
\usepackage{xcolor}
\let\svat @
\catcode`@=\active
\def@{\textcolor{red}{\svat}}
\begin{document}
xy@z
\end{document}