acro 包:使用长表将翻译移至下一行

acro 包:使用长表将翻译移至下一行

我有一个类似这里描述的类似问题:acro:仅将选定的缩写词的翻译移至下一行

我想要下一行中的条目类型为“foreign”,但具有预定义样式“longtable”。

我尝试使用上面链接中提到的@cgnieder的代码,但没有成功。我只是从acro源代码中复制了longtable样式的部分,但pdf中“foreign”的()很奇怪。“foreign”条目中写入的文本的位置也不在下一行。

我的代码如下,希望有人能帮助我?

在此处输入图片描述

\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[english,ngerman]{babel}
\usepackage{acro}
\usepackage{enumitem}
\usepackage{longtable}
\usepackage{array}

\DeclareAcroProperty?{foreign-newline}

% copied custom style from link above
\NewAcroTemplate[list]{custom}{
  \acroheading
  \acropreamble
  \begin{description}[
    labelwidth = 3em ,
    leftmargin = 3.5em ,
    noitemsep ,
    itemindent = 0pt]
    \acronymsmapF{%
      \item[\acrowrite{short}\acroifT{alt}{/}\acrowrite{alt}:]%
        \acrowrite{list}%
        \acroifT{foreign}{%
          \acroifbooleanTF{foreign-newline}{\newline}{ }%
          (\textit{\acrowrite{foreign}})
        }%
    }
    { \item \AcroRerun }%
  \end{description}%
}

% modified longtable style to have "foreign" in next line
\NewAcroTemplate[list]{longtablenew}{
    \AcroNeedPackage{array,longtable}
    \acronymsmapF{
        \AcroAddRow{
            \acrowrite{short}
            \acroifT{alt}{/}\acrowrite{alt}
            &
            \acrowrite{list}
            \acroifanyT{foreign,extra}{~(}
            \acrowrite{foreign}
            \acroifallT{foreign,extra}{,~}
            \acrowrite{extra}
            \acroifanyT{foreign,extra}{)}
            \acroifbooleanTF{foreign-newline}{\newline}{ }%
          (\textit{\acrowrite{foreign}})
            \acropagefill
            \acropages
              { \acrotranslate {page} \nobreakspace }
              { \acrotranslate {pages} \nobreakspace }
            \tabularnewline
          }
      }
      { \AcroRerun }  
    \acroheading
    \acropreamble
    \par \noindent
    \begin{longtable} {>{\bfseries}lp{.7\linewidth}}
      \AcronymTable
    \end{longtable}
  }

% Original longtable style copied from github
\NewAcroTemplate[list]{longtableOrig}{
    \AcroNeedPackage{array,longtable}
    \acronymsmapF{
        \AcroAddRow{
            \acrowrite{short}
            \acroifT{alt}{/}\acrowrite{alt}
            &
            \acrowrite{list}
            \acroifanyT{foreign,extra}{~(}
            \acrowrite{foreign}
            \acroifallT{foreign,extra}{,~}
            \acrowrite{extra}
            \acroifanyT{foreign,extra}{)}
            \acropagefill
            \acropages
              { \acrotranslate {page} \nobreakspace }
              { \acrotranslate {pages} \nobreakspace }
            \tabularnewline
          }
      }
      { \AcroRerun }  
    \acroheading
    \acropreamble
    \par \noindent
    \begin{longtable} {>{\bfseries}lp{.7\linewidth}}
      \AcronymTable
    \end{longtable}
  }


\acsetup{
  list/template = longtablenew
}

\DeclareAcronym{dir}{
  short = DIR. ,
  long = Direkte Information durch Recherche ,
  foreign = direct information through investigation ,
  foreign-newline = true,
  foreign-babel = english
}
\DeclareAcronym{benutzer}{
  short = Betz. ,
  long = Benutzer ,
  foreign = User ,
  foreign-babel = english ,
  foreign-newline = true
}


\begin{document}

\acuseall

\printacronyms

\end{document}

新的相关问题:

我现在有一些没有外来词条的首字母缩略词。当我使用@Simon Dispa 的以下代码(两个版本都这样做)时,每个没有外来长词的首字母缩略词都会得到空括号 ()。我怎样才能让只有带有外来词的首字母缩略词的 () 填满?我怎样才能去掉没有外来词条的空 ()?您可以在图片中看到我对首字母缩略词“Ts.”的意思。我使用了以下代码:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[english,ngerman]{babel}
\usepackage{acro}
% \usepackage{enumitem}
\usepackage{longtable}
\usepackage{array}  

%% modified longtable style to have "foreign" in next line
\NewAcroTemplate[list]{LongtableForeign}
{
    \AcroNeedPackage {array,longtable}
    \acronymsmapF
    {
        \AcroAddRow
        {
            \acrowrite {short}
            \acroifT {alt} { / } \acrowrite {alt}
            &
            \acrowrite {list}
            \newline
            (\acrowrite{foreign})   
            \acropagefill
            \acropages
            { \acrotranslate {page} \nobreakspace }
            { \acrotranslate {pages} \nobreakspace }
            \tabularnewline
        }
    }
    { \AcroRerun }  
    \acroheading
    \acropreamble
    \par \noindent
    \begin {longtable} {>{\bfseries}lp{.7\linewidth}}
    \AcronymTable
    \end {longtable}
}

\acsetup{list/template = LongtableForeign, foreign-format=\emph} % <<<<<<<<<<<

\DeclareAcronym{dir}{
    short =DIR.,
    long = Direkte Information durch Recherche,
    foreign = direct information through investigation,
    foreign-babel = english
}
\DeclareAcronym{benutzer}{
    short =Betz.,
    long =Benutzer,
    foreign =User,
    foreign-babel = english,
}

\begin{document}        
    \acuseall       
    \printacronyms      
\end{document}

在此处输入图片描述

答案1

后续跟进后更新

F

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[english,ngerman]{babel}
\usepackage{acro}
\usepackage{enumitem}
\usepackage{longtable}
\usepackage{array}

\DeclareAcroProperty?{foreign-newline}

%% modified longtable style to have "foreign" in next line
\NewAcroTemplate[list]{LongtableForeign}
{
    \AcroNeedPackage {array,longtable}
    \acronymsmapF
    {
        \AcroAddRow
        {
            \acrowrite {short}
            \acroifT {alt} { / } \acrowrite {alt}
            &
            \acrowrite {list}
            \acroifbooleanTF{foreign-newline}{%
                \newline
            \itshape \acroifT{foreign}{(}\acrowrite{foreign}\acroifT{foreign}{)}}
            {\itshape \acroifT{foreign}{(}\acrowrite{foreign}\acroifT{foreign}{)}}%     
            \acropagefill
            \acropages
            {\acrotranslate {page} \nobreakspace }
            {\acrotranslate {pages} \nobreakspace }
            \tabularnewline
        }
    }
    { \AcroRerun }  
    \acroheading
    \acropreamble
    \par \noindent
    \begin {longtable} {>{\bfseries}lp{.7\linewidth}}
    \AcronymTable
    \end {longtable}
}

\acsetup{list/template = LongtableForeign}%

\DeclareAcronym{dir}{
    short =DIR.,
    long = Direkte Information durch Recherche,
    foreign = direct information through investigation,
    foreign-newline = true,
    foreign-babel = english
}
\DeclareAcronym{benutzer}{
    short =Betz.,
    long =Benutzer,
    foreign =User,
    %   foreign-newline = true,,% stay in the same line OR foreign-newline = false
    foreign-babel = english,
}

\DeclareAcronym{test}{
    short = Ts. ,
    long = Test ,
}

\begin{document}
    
    \acuseall
    
    \printacronyms
    
\end{document}

相关内容