.png)
나는 약간의 텍스트/최소한의 HTML 코드를 생성된 텍스트 상자에 넣고 싶었습니다. HTML(두 개는 <br>
나 <a href='link'>
에게 중요하지 않으므로 minted의 언어에 텍스트 옵션을 사용하기로 선택했습니다. 그러나 HTML 요소가 아닌 몇 가지 사항을 빨간색 텍스트로 강조하고 싶습니다. 예를 들면 다음과 같습니다.
Go to this link <a href="domain.com/upload/[UPLOAD_ID]"> to find your upload.
[UPLOAD_ID]
나는 빨간색으로 표시하고 싶습니다 . 이를 수행할 수 있는 방법이 있습니까? 감사해요!
답변1
작성된 문서에는 다음과 같이 텍스트를 강조 표시하는 방법이 있습니다.
내가 아는 한, 이는 발행된 환경을 탈출하고 \colorbox
명령을 실행함으로써 달성됩니다. minted에서 작동하도록 하는 \textcolor
대신 user187803에 표시된 대로 명령을 사용할 수 있습니다 .\colorbox
예:
\begin{minted}[escapeinside=||]{py}
def f(x):
y = x|\textcolor{red}{**}|2
return y
\end{minted}
결과:
이를 예제에 적용하면 밑줄을 [UPLOAD_ID]
백슬래시로 이스케이프해야 합니다 [UPLOAD\_ID]
. 이는 밑줄이 일반적으로 문자를 색인화하는 데 사용되기 때문에 필요합니다. 그러나 이 경우 밑줄은 밑줄로 인쇄되어야 하며 에서 색인을 만드는 것으로 해석되어서는 안 됩니다 ID
. 여기서 백슬래시를 사용하지 않으면 오류가 발생합니다.
제공된 예:
\begin{minted}[escapeinside=||]{text}
Go to this link <a href="domain.com/upload/|\textcolor{red}{[UPLOAD\_ID]}|"> to find your upload
\end{minted}
답변2
사용을 고집하지 않으면 minted
다음과 같이 작동합니다.
\documentclass{article}
\usepackage{fancyvrb}
\usepackage{xcolor}
\begin{document}
\begin{Verbatim}[commandchars=\\\{\}]
Go to this link <a href="domain.com/upload/\textcolor{red}{[UPLOAD_ID]}"> to find your upload.
\end{Verbatim}
\fvset{commandchars=\\\{\}}
Go to this link \Verb|<a href="domain.com/upload/\textcolor{red}{[UPLOAD_ID]}">| to find your upload.
\end{document}