완전히 확장된 결과를 단순 문자열로 사용(citet 및 \IfSubStr 포함)

완전히 확장된 결과를 단순 문자열로 사용(citet 및 \IfSubStr 포함)

나는 인터넷에서 도움이 될 만한 것을 찾지 못한 채 그 문제로 머리가 아프게 되었습니다.

초기 문제는 프랑스어로 에세이를 작성하지만 영어로 작성된 일부 기사를 포함해야 하므로 인용 스타일이 다르다는 것입니다. 프랑스어가 주요 언어이므로 "Name1"로 인용하는 패키지 unsrtnat-fr의 참고문헌 스타일을 사용합니다.natbibName2"(저자 2명)를 사용합니다 \citet. 주어진 영어 부분 "Name1에 대한 일반 스타일을 복구하고 싶습니다.그리고이름". 내 솔루션은 사용자 정의 명령을 정의하는 것입니다 \encitet." 엣 "~에 의해" 그리고 "의 결과로 \citet.

다른 정의를 시도했지만 결국 어떻게 해야 하는지 이해할 수 없습니다... 매번 인수 확장에 문제가 있습니다.

내가 정의하고 싶은 명령의 의사 코드는 다음과 같습니다.

\newcommand{\encitet}[1]{%
% 1 : store the result of \citet{#1} in tmp (as a simple string)
% 2 : test if 'et al.' is found into the string
% 3 : if found then return tmp 
% 4 : else return the replacement of every " et " by " and " in tmp
}

테스트에 사용하는 TeX 파일은 다음과 같습니다.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{trace}
\usepackage{xspace}
\usepackage{xstring}
\usepackage{etoolbox}
\usepackage{stringstrings}
\usepackage[square,numbers]{natbib}
\bibliographystyle{abbrvnat-fr}

% Here is the problem
\newcommand{\encitet}[1]{%
    \def\tmp{\expandafter\citet{#1}}%
    %\edef\tmp\expandafter{\mytemp{#1}}%
    %
    \expandafter\IfSubStr{\tmp}{et al.}{%
        \tmp%
    }{%
        \StrSubstitute{\tmp}{ et }{ and }%
    }\xspace%
}

% Example that works
\newcommand{\encitett}[1]{%
    \def\mytemp{\expandafter\citet{#1}}%
    \expandafter\ifstrequal\mytemp{#1}{a}{"a" was given}{not a}, %
    \expandafter\ifstrequal\mytemp{#1}{b}{"b" was given}{not b}%
}


\begin{document}

% Example with two authors
\encitet{einstein}

% Example with more than two authors 
\encitet{latexcompanion}


\citep{knuthwebsite}


\medskip

\bibliography{sample}

\end{document}

그리고 턱받이 파일 :

@article{einstein,
    author =       "Albert Einstein and AnotherGuy ForTheTest",
    title =        "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
        [{On} the electrodynamics of moving bodies]",
    journal =      "Annalen der Physik",
    volume =       "322",
    number =       "10",
    pages =        "891--921",
    year =         "1905",
    DOI =          "http://dx.doi.org/10.1002/andp.19053221004"
}

@book{latexcompanion,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The \LaTeX\ Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}

@misc{knuthwebsite,
    author    = "Donald Knuth",
    title     = "Knuth: Computers and Typesetting",
    url       = "http://www-cs-faculty.stanford.edu/\~{}uno/abcde.html"
}

그리고 컴파일 명령은 다음과 같습니다.

pdflatex test.tex && pdflatex test.tex && bibtex test && pdflatex test.tex && pdflatex test.tex

귀하의 도움에 미리 감사드립니다.

답변1

이것은 작동하지 않습니다. \citet은 매우 복잡한 매크로이므로 간단한 방법으로는 출력을 검색할 수 없습니다. 정말로 natbib(biblatex 언어 지원이 내장되어 있음)을 고수하려면 .bst 파일을 조작해야 합니다. 문서 폴더에 다른 이름으로 저장한 후 고정된 단어를 변경하여 명령을 내리도록 하세요. 예:

FUNCTION{fr.and}{       %% le "et" entre les deux derniers auteurs
" \authorand{} "
}

그런 다음 문서에서 명령에 합리적인 정의를 제공할 수 있습니다.

관련 정보