설명된 패키지를 사용하고 있습니다.여기태그 기반 기사를 작성합니다.
테이블을 만드는 데 사용되는 csv 문자열 목록이 있고 csv 문자열의 첫 번째 인스턴스도 태그로 사용하고 싶습니다.
\listadd\aka{DVM , Distillation with value matching, RL}
\listadd\aka{RL , Reinforcement Learning, RL }
\listadd\aka{MARL , Multi agent reinforcement learning, RL }
\listadd\aka{RND , random network distillation, Novelty RL }
\listadd\aka{DRL , Deep reinforcement learning, RL }
\listadd\aka{MADRL , Multi agent Deep reinforcement learning, RL }
\listadd\aka{NLP , Natural language processing, NLP}
\listadd\aka{EM ,Emergent communication, EM}
\listadd\aka{LtT , Learning to teach , RL}
\listadd\aka{AA, Action advising , LtT }
\listadd\aka{TB, teacher budget, LtT }
\listadd\aka{CA, Continuous Actions, RL }
\listadd\aka{DA, Discrete Actions, RL}
\listadd\aka{NN, Noisy Nets , General }
\listadd\aka{SiA , Student initiated approach , LtT }
\listadd\aka{JiA , Joint initiated approach , LtT }
\listadd\aka{TiA , Teacher initiated approach , LtT }
\listadd\aka{DDS , Dynamic difficulty scaling , Flow}
\listadd\aka{BB , Believable bots , Flow}
\listadd\aka{ToF , Theory of flow , Flow}
\listadd\aka{GBL , Game-based learning , Flow}
\listadd\aka{HRL , Hierarchical reinforcement learning , RL}
\newcommand{\addtag}[1]{
\readlist*\mylist{#1} \declaretag{\mylist[1]}}
\newcommand*{\addtags}{\forlistloop{\addtag}{\aka}}
명령을 실행 addtags
하고 addtag
목록을 반복하고 첫 번째 csv 요소( \readlist*\mylist{#1}
) 를 가져와 declaretag
함께 사용합니다. addtags
문서에서 사용하려고 하면 a가 제공 LaTex Error: No counter '1' defined
되고 마지막 태그만 고려하는 것 같습니다. 반면에 다음 declaretag
과 같이 사용하는 경우:
\declaretag{DVM}
\declaretag{RL}
...
\declaretag{HRL}
잘 작동합니다.
내가 도대체 뭘 잘못하고있는 겁니까?
편집 1
추가 정보 요청에 답변하기 위해 편집 중입니다.
따라서 내 실제 목표는 관련 설명 및 도메인(쉼표로 구분된 값)이 포함된 태그 목록(일명)을 유지하는 것입니다.
이 목록은 다음으로 표를 채우는 데 사용됩니다.
% create row with three elements
\newcommand{\fillrow}[1]{
\readlist*\mylist{#1} \mylist[1] & %
\readlist*\mylist{#1} \mylist[2] & %
\readlist*\mylist{#1} \mylist[3] \\ \hline
}
% fill tabular
\newcommand*{\filltab}{\forlistloop{\fillrow}{\aka}}
tagstoc
그리고 나는 그것이 만든 패키지 와 함께 작동하고 싶습니다라이언 라이히 여기:
\usepackage{filecontents}
% Here's the package file
\begin{filecontents*}{tagstoc.sty}
\usepackage{tocloft,etoolbox}
% Declare the master TOC. This will contain:
% * A list of tags
% * A sequence of entries where tags are referenced
% and it will be used multiple times to generate lists of tag usage
\newlistof{tags}{tags}{All tags}
\renewcommand*\cfttagstitlefont{\Large\bfseries}% For example
% Use this in the preamble to make a new tag.
\newcommand*\declaretag[1]{%
\newlistentry[tags]{tag#1}{tags}{0}%
\listadd\Tags{#1}%
\addtocontents{tags}{(#1) }%
}
% This is only true when printing the list of tags
\newif\ifprintingtags
% This makes sure that the list of tags is not printed most of the time...
\addtocontents{tags}{\protect\ifprintingtags}
% ...because it wraps the entire TOC from the preamble
\AtBeginDocument{\addtocontents{tags}{\protect\fi}}
% This is a rather inefficient way to selectively print particular tags.
% Presumably, I should just pop each tag from the list as I go,
% but etoolbox doesn't seem to handle stacks. Probably I'm missing something.
\newcommand*\deactivatetag[1]{%
\expandafter\let\csname l@tag#1\endcsname=\@gobbletwo
}
\newcommand*\activatetag[1]{%
\forlistloop\deactivatetag\Tags
\expandafter\let\csname l@tag#1\endcsname=\l@section
}
% These are hooks for the user
\providecommand*\currenttag{}
\providecommand*\listoftagstitle{}
% This prints all the references to a particular tag.
% Effectively, it's a partial ToC for that tag.
\newcommand*\dotag[1]{%
\renewcommand*\currenttag{#1}%
\begingroup
\activatetag{#1}%
\section*{\listoftagstitle}%
\@input{\jobname.tags}%
\endgroup
}%
% This prints the snippets, placed (with repeats) beneath their tags.
% It also prints a list of defined tags, more or less as an excuse
% to have \listoftags handle the .tags auxiliary ToC file.
\newcommand*\snippetsbytag{%
\forlistloop\dotag\Tags
\activatetag{}
\printingtagstrue
\listoftags
}
% This is how to proclaim a snippet, which is what gets tagged.
\newcounter{snippet}
\providecommand*\snippetname{}
\newcommand*\snippettitle{\snippetname}
\newcommand*\snippet[1]{%
\refstepcounter{snippet}%
\renewcommand*\snippetname{#1}%
\noindent{\normalsize\bfseries\snippettitle.}%
}
% In case of no hyperref
\providecommand\phantomsection{}
% This is how you place a tag beneath a snippet.
\newcommand*\placetag[1]{%
\phantomsection% In case of hyperref
\addcontentsline{tags}{tag#1}{\snippettitle}%
(tag~#1)%
}
\end{filecontents*}
\usepackage{tagstoc}
\renewcommand*\listoftagstitle{Snippets tagged with \currenttag}
% Preferred way to declare tags. They will be printed in this order.
따라서 내가 시도한 것과 같은 사용자 정의 명령을 사용하여 목록의 모든 태그를 추가하려면 다음을 수행하십시오.
\newcommand{\addtag}[1]{
\readlist*\mylist{#1} \declaretag{\mylist[1]}}
\newcommand*{\addtags}{\forlistloop{\addtag}{\aka}}
그러나 그것을 사용하면 모든 것이 이상해지고 목록의 마지막 요소(HRL)가 22번 반복됩니다(목록의 요소).
이것이 명확해지기를 바랍니다.
편집 2
확인할 수 있는 작업 문서를 추가하고 있습니다.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[colorlinks]{hyperref}
\usepackage[table,xcdraw]{xcolor}
\usepackage{filecontents}
% Here's the package file
\begin{filecontents*}{tagstoc.sty}
\usepackage{tocloft,etoolbox}
% Declare the master TOC. This will contain:
% * A list of tags
% * A sequence of entries where tags are referenced
% and it will be used multiple times to generate lists of tag usage
\newlistof{tags}{tags}{All tags}
\renewcommand*\cfttagstitlefont{\Large\bfseries}% For example
% Use this in the preamble to make a new tag.
\newcommand*\declaretag[1]{%
\newlistentry[tags]{tag#1}{tags}{0}%
\listadd\Tags{#1}%
\addtocontents{tags}{(#1) }%
}
% This is only true when printing the list of tags
\newif\ifprintingtags
% This makes sure that the list of tags is not printed most of the time...
\addtocontents{tags}{\protect\ifprintingtags}
% ...because it wraps the entire TOC from the preamble
\AtBeginDocument{\addtocontents{tags}{\protect\fi}}
% This is a rather inefficient way to selectively print particular tags.
% Presumably, I should just pop each tag from the list as I go,
% but etoolbox doesn't seem to handle stacks. Probably I'm missing something.
\newcommand*\deactivatetag[1]{%
\expandafter\let\csname l@tag#1\endcsname=\@gobbletwo
}
\newcommand*\activatetag[1]{%
\forlistloop\deactivatetag\Tags
\expandafter\let\csname l@tag#1\endcsname=\l@section
}
% These are hooks for the user
\providecommand*\currenttag{}
\providecommand*\listoftagstitle{}
% This prints all the references to a particular tag.
% Effectively, it's a partial ToC for that tag.
\newcommand*\dotag[1]{%
\renewcommand*\currenttag{#1}%
\begingroup
\activatetag{#1}%
\section*{\listoftagstitle}%
\@input{\jobname.tags}%
\endgroup
}%
% This prints the snippets, placed (with repeats) beneath their tags.
% It also prints a list of defined tags, more or less as an excuse
% to have \listoftags handle the .tags auxiliary ToC file.
\newcommand*\snippetsbytag{%
\forlistloop\dotag\Tags
\activatetag{}
\printingtagstrue
\listoftags
}
% This is how to proclaim a snippet, which is what gets tagged.
\newcounter{snippet}
\providecommand*\snippetname{}
\newcommand*\snippettitle{\snippetname}
\newcommand*\snippet[1]{%
\refstepcounter{snippet}%
\renewcommand*\snippetname{#1}%
\noindent{\normalsize\bfseries\snippettitle.}%
}
% In case of no hyperref
\providecommand\phantomsection{}
% This is how you place a tag beneath a snippet.
\newcommand*\placetag[1]{%
\phantomsection% In case of hyperref
\addcontentsline{tags}{tag#1}{\snippettitle}%
(tag~#1)%
}
\end{filecontents*}
\usepackage{tagstoc}
\renewcommand*\listoftagstitle{Snippets tagged with \currenttag}
% Preferred way to declare tags. They will be printed in this order.
\usepackage{etoolbox}
\usepackage{listofitems}
% create row with three elements
\newcommand{\fillrow}[1]{
\readlist*\mylist{#1} \mylist[1] & %
\readlist*\mylist{#1} \mylist[2] & %
\readlist*\mylist{#1} \mylist[3] \\ \hline
}
% fill tabular
\newcommand*{\filltab}{\forlistloop{\fillrow}{\aka}}
\listadd\aka{DVM , Distillation with value matching, RL}
\listadd\aka{RL , Reinforcement Learning, RL }
\listadd\aka{MARL , Multi agent reinforcement learning, RL }
\listadd\aka{RND , random network distillation, Novelty RL }
\listadd\aka{DRL , Deep reinforcement learning, RL }
\listadd\aka{MADRL , Multi agent Deep reinforcement learning, RL }
\listadd\aka{NLP , Natural language processing, NLP}
\listadd\aka{EM ,Emergent communication, EM}
\listadd\aka{LtT , Learning to teach , RL}
\listadd\aka{AA, Action advising , LtT }
\listadd\aka{TB, teacher budget, LtT }
\listadd\aka{CA, Continuous Actions, RL }
\listadd\aka{DA, Discrete Actions, RL}
\listadd\aka{NN, Noisy Nets , General }
\listadd\aka{SiA , Student initiated approach , LtT }
\listadd\aka{JiA , Joint initiated approach , LtT }
\listadd\aka{TiA , Teacher initiated approach , LtT }
\listadd\aka{DDS , Dynamic difficulty scaling , Flow}
\listadd\aka{BB , Believable bots , Flow}
\listadd\aka{ToF , Theory of flow , Flow}
\listadd\aka{GBL , Game-based learning , Flow}
\listadd\aka{HRL , Hierarchical reinforcement learning , RL}
\newcommand{\addtag}[1]{
\readlist*\mylist{#1} \declaretag{\mylist[1]}}
\newcommand*{\addtags}{\forlistloop{\addtag}{\aka}}
\begin{document}
\addtags
\snippetsbytag
\newpage
\renewcommand{\arraystretch}{1.7}
% Please add the following required packages to your document preamble:
% \usepackage[table,xcdraw]{xcolor}
% If you use beamer only pass "xcolor=table" option, i.e. \documentclass[xcolor=table]{beamer}
\begin{table}[!h]
\centering
\begin{tabular}{|lll|}
\rowcolor[HTML]{C0C0C0}
\textbf{Aka} & \textbf{Definition} & \textbf{Field} \\ \hline
\filltab
\end{tabular}
\caption{List of acrimonious with corresponding description and field}
\label{tab:akas}
\end{table}
\newpage
\snippet{TMp1}
\placetag{SiA}\placetag{NN}\placetag{TiA }
Something
\snippet{TMp2}
\placetag{MADRL}\placetag{HRL}\placetag{TiA }
Something else
\end{document}