KTUG마당은 KTUG를 방문하는 모든 이용자가 대화를 나누고 소식을 전하는 곳입니다.
- 로그인 없이 자유롭게 글을 읽고 쓸 수 있는 철학은 처음과 같이 계속됩니다.
- Team Blog의 글을 이곳 게시판의 "정보글"로 모았습니다. Team blog는 기고자가 올린 글에 질문을 받는 부담을 줄이기 위하여 댓글을 허용하지 않았습니다. 그러나 이곳 게시판으로 모으면서 댓글을 달 수 있습니다. 게시물을 작성하실 때 댓글을 원하지 않으시면 댓글을 허용하시지 않으시기를 바랍니다. 또한 불필요한 소모성 댓글을 달지 않도록 주의하여 주시기를 바랍니다.
- TeX과 관련된 질문이나 답변은 QnA 마당을 이용하십시오. TeX과 관련된 질문은 지웁니다
- MathJax를 이용한 수식조판을 사용하실 수 있습니다. 여기를 참조하세요.
- 스팸 글을 막기 위하여 짧은 시간 내에 다시 글이 등록되는 IP를 막거나, 광고 글을 막기 위하여 금지어로 .com, .net 등을 설정하고 있습니다. 다소간의 불편함이 있으시더라도 양해 바랍니다.
- 금지어에서 stackexchange, stackoverflow, ctan, overleaf, , github, google.com, gmail.com, .org, .io, sil.org, wiki.com, tistory.com등은 해제하였습니다.
- 사용하는 편집기는 CKeditor입니다. 편집기에서 [enter]를 누르면 <p> 태그가 들어가고, 문단으로 생각하고 한줄을 비웁니다. 글줄만 바꾸려면 shift-enter 를 누르시면 <BR>가 들어가므로 용도에 맞게 나누어 쓸 수 있습니다.
자유글 yihoze님의 지워진 글에 대한 코멘트
2023.12.05 20:04
게시글이 올라온 것을 보고 한참 답변글을 작성하다가 submit 버튼을 눌렀더니 그런 글이 없다네요.
분한 마음에(^^) hoze님의 블로그를 찾아가서 같은 주제의 새 포스팅을 보고 간략히 답변을 답니다.
%!TEX program = lualatex \documentclass{article} \usepackage{luacode} \usepackage[svgnames]{xcolor} \newcommand*\myHighlight[1]{\textcolor{blue}{\itshape #1}} \newcommand*\dream[1]{\textcolor{SeaGreen}{\bfseries #1}} \begin{luacode} function Replace_some_words ( s ) s = s:gsub ( "([^\\])freedom", "%1\\myHighlight{freedom}" ) s = s:gsub ( "([^\\])dream", "%1\\myHighlight{dream}" ) s = s:gsub ( "([^in\\])justice", "%1\\myHighlight{justice}" ) return s end \end{luacode} \luaexec{ luatexbase.add_to_callback ("process_input_buffer", Replace_some_words, "justice_justice") } \begin{document} I have a dream. It is obvious today that \dream{America} has defaulted on this promissory note, insofar as her citizens of color are concerned. Instead of honoring this sacred obligation, America has given the Negro people a bad check, a check which has come back marked insufficient funds. But we refuse to believe that the bank of justice is bankrupt. We refuse to believe that there are insufficient funds in the great vaults of opportunity of this nation. And so, we've come to cash this check, a check that will give us upon demand the riches of freedom and the security of justice. We have also come to this hallowed spot to remind America of the fierce urgency of now. This is no time to engage in the luxury of cooling off or to take the tranquilizing drug of gradualism. Now is the time to make real the promises of democracy. Now is the time to rise from the \dream{dark and desolate valley of segregation} to the sunlit path of racial justice. Now is the time to lift our nation from the quicksands of racial injustice to the solid rock of brotherhood. Now is the time to make justice a reality for all of God's children. \end{document}
코멘트를 작성하려 한 이유는 만약에 \dream이라는 매크로가 있을 경우에 어떻게 할 것인가라는 생각 때문이었습니다.
댓글 5
-
yihoze
2023.12.06 09:23
-
noname
2023.12.06 09:39
injustice는 색칠하지 않는다지만 Justice는 해야 하지 않을까요? 첫 글자가 대문자인 경우도 걸리도록 수정할 필요가... ;)
-
yihoze
2023.12.06 10:04
작나님이 제시했던 코드(http://www.ktug.org/xe/index.php?mid=KTUG_open_board&document_srl=242696)에서 미흡하다고 생각했던 점이 (결국 삭제한 내용을 되풀이하게 되네요)
1) 강조할 단어들을 여럿 지정할 수 있어야 한다.
2) 딱 들어맞는 말만 강조되어야 한다.
3) 강조 기능을 켜고 끌 수 있어야 한다.그런데 영어는 대소문자가 있으니, 대소문자 변환 처리를 추가해야 더 멋질 것 같기도 합니다. 하지만 그것을 구현하는 코드 만들기는 너무 복잡하고 수고스러운 데 비해 (알파벳인지 아닌지도 따져야 하고), 사전에 대문자 단어를 추가하는 것은 아주 간단합니다.
local dict = {"freedom", "justice", "Justice", "dream"}
사실 이 생각은 일전에 철자 검사기를 만들면서 갖게 되었습니다. 그러니까 제 의도는 목록에 포함된 단어들에 딱(!) 들어맞는 것만 찾게 하자는 겁니다.
-
noname
2023.12.06 12:06
네 그렇군요.
대단한 건 아니지만 소소하게 이런 방법은 어떨까요?
function highword(dict) local dict = dict return function (s) for _, w in ipairs(dict) do s = s:gsub("([^\\])(%f[%a]"..w.."%f[%A])", "%1\\texthi{%2}") s = s:gsub("("..w:gsub("^%l", string.upper)..")", "\\dream{%1}") s = s:gsub("("..w:gsub("%a", string.upper)..")", "\\dream{%1}") end return s end end
-
yihoze
2023.12.06 13:36
justice, Justice, JUSTICE만이 현실에서 쓰일 것이니 합리적인 방법이라고 생각됩니다.
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
882 | MiKTeX 인스톨 가이드를 완성해주세요 [29] | noname | 2023.01.27 | 1396 |
881 | 예전 샘플 문서 갱신: 금강경 | noname | 2024.05.15 | 145 |
880 | 텍으로 작성된 인문사회계 논문 [1] | 판돌이 | 2024.05.05 | 245 |
879 | La TeX 라텍 작성 하실 분 구합니다. [2] | LaTex | 2024.05.04 | 270 |
878 | 이태준 《문장강화》 조판 재현 [6] | noname | 2020.04.27 | 3898 |
877 | daft text [1] | noname | 2024.04.29 | 146 |
876 | [취미] 심심할 때는 괘를 뽑아보세요 [1] | noname | 2024.04.16 | 222 |
875 | [잡담] 이과가 사랑에 빠졌기에... [6] | noname | 2024.04.09 | 246 |
874 | [Lilypond] W. A. Mozart, Laudate Dominum [3] | noname | 2024.04.07 | 149 |
873 | local.conf와 fc-list [4] | yihoze | 2024.03.28 | 239 |
872 | 터잡기 [5] | yihoze | 2023.02.17 | 368 |
871 | 텍라이브 2024 pretest를 깔아보았습니다 [8] | Progress | 2024.03.13 | 406 |
870 | 게임 테이블 그리기 3 - 3인 게임 | ischo | 2024.02.14 | 262 |
869 | 게임 테이블 그리기 5 - 혼합전략 | ischo | 2024.02.16 | 244 |
868 | 게임 테이블 그리기 4 - 제로섬 게임 [4] | ischo | 2024.02.14 | 304 |
867 | 게임 테이블 그리기 2 | ischo | 2024.02.14 | 175 |
866 | 게임 테이블 그리기 1 [8] | ischo | 2024.02.03 | 407 |
865 | lilypond와 LaTeX [6] | cantabile | 2018.03.05 | 6804 |
864 | 세벌식 직결 글꼴의 추억 [7] | noname | 2023.11.27 | 455 |
863 | 공동번역 성서 조판 형태의 재현 [5] | noname | 2024.01.22 | 354 |
올리고 나서 공유할 만한 정도의 것은 아니라 생각해서 삭제했는데, 죄송합니다. 강조할 단어가 동시에 매크로 이름으로 사용되는 문제에 대해서는---그런 매크로를 만들지 않는 것이 가장 편하고 실행 가능한 방법이라 생각합니다만--- 백슬래시로 시작하는 단어는 배제해야 하니, 정규식에 ([^\\])를 추가했습니다.
\NewDocumentCommand{\dream}{m}{\textcolor{green}{#1}}
\NewDocumentCommand{\texthi}{m}{\textcolor{blue}{\itshape #1}}
\begin{luacode*}
function highword(dict)
local dict = dict
return function (line)
for _, w in ipairs(dict) do
line = string.gsub(line, "([^\\])(%f[%a]"..w.."%f[%A])", "%1\\texthi{%2}")
end
return line
end
end
function enableHighword()
local dict = {"freedom", "justice", "dream"}
luatexbase.add_to_callback("process_input_buffer", highword(dict), "highword")
end
function disableHighword()
luatexbase.remove_from_callback("process_input_buffer", "highword")
end
\end{luacode*}