문서 전체에서 이탤릭체로 표시할 단어 집합을 지정할 수 있나요?

문서 전체에서 이탤릭체로 표시할 단어 집합을 지정할 수 있나요?

나는 영어 단어도 포함하는 이탈리아어로 문서를 작성하고 있습니다. 모든 영어 단어를 이탤릭체로 표시하고 싶지만 문서 전체에서 해당 단어가 나오는 것을 모두 찾고 싶지는 않습니다. 문서를 컴파일할 때 이탤릭체로 표시되도록 단어 집합을 지정하는 무언가(아마도 명령?)를 만드는 것이 가능하기를 바랍니다. 어쩌면 모든 영어 단어가 자동으로 이탤릭체로 표시되도록 하는 것도 가능할 수도 있습니다. 지금까지 내 질문에 답할 수 있는 내용을 찾지 못했습니다.이것, 그러나 문제는 특정 단어에만 적용되는 반면 단어 집합을 지정해야 한다는 것입니다.

답변1

간단한 수정이 답변:

\documentclass{article}
\usepackage{xesearch}
\UndoBoundary{-} % allow hyphens!!
\SearchList{italics}{\emph{#1}}{antibod?,covid?,infection,rna,DNA,*ELISA,*WHO,?pcr,%
RT-pcr,Multiplex-PCR,usa,UK,SARS?,virus,sensit?,test?}
\begin{document}
Mr. So and So, from the 
WHO, % organization,   
who % common word, must be not changed
has announced yesterday in the UK and the USA that the 
ELISA % method acronym, must be changed  
test to detect antibodies against SARS-CoV-2  
in COVID-19 patients with first signs of the disease is useless,  
said now that even PCR methods, 
like RT-PCR  
nested PCR, 
quantitative PCR, 
and Multiplex-PCR test,       
used too early in the course of infection 
are not enough sensitives.
On the other hand, the researcher  
Elisa % Woman name, must be not changed
 Whoknow proposed a WHO meetings to discuss the 
disgnostic protocols of SARS and RNA virus and  the sensitivity of a new indirect antibody test.  
\StopList{italics}
\end{document}

답변2

LuaLaTeX 기반 솔루션은 다음과 같습니다. 쉼표로 구분된 단어 목록을 Lua 테이블로 설정하는 방법을 보여주고, 입력을 스윕하고 테이블의 단어 중 하나와 일치하는 모든 단어를 이탤릭체로 렌더링하는 Lua 함수를 설정합니다.

이 코드는 강력하지 않습니다. 예를 들어 문서에 매크로 \foxhound나 환경이 포함되어 있으면 foxbat매우 나쁜 일이 발생할 수 있습니다.

문서에 있는 영어 단어의 모든 인스턴스를 명령문에 수동으로 포함하는 것이 더 나을 것이라고 생각합니다 \textit.

여기에 이미지 설명을 입력하세요

% !TEX TS-program = lualatex
\documentclass{article}
\usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage[english,italian]{babel}
\usepackage{luacode}
%% Lua-side code: (a) Lua table with English words, 
%% (b) Lua function that renders words in the table in italics
\begin{luacode}
en_words_list = {"The","quick","brown","fox","jumps","over","the","lazy","dog"}
function italicize_english_words ( s )
  for i=1,#en_words_list do
    s = s:gsub ( en_words_list[i] , "\\textit{%0}" )
  end
  return s
end
\end{luacode}
%% LaTeX-side code: Macros to activate/deactivate the Lua function:
\newcommand\EnWordsOn{\directlua{
    luatexbase.add_to_callback(
   "process_input_buffer" , italicize_english_words , "enwords" )}}
\newcommand\EnWordsOff{\directlua{
   luatexbase.remove_from_callback(
   "process_input_buffer" , "enwords" )}}
   
\begin{document}
\EnWordsOn % Activate the Lua function

la rapida volpe marrone---the quick brown fox---salta sopra---jumps over---il cane pigro---the lazy dog
\end{document}

관련 정보