2016-08-09 4 views
0

.texファイルで使用するために作成された長い参考文献ファイルがあり、自分の引用が太字で表示されるように修正したいと考えています。これは、私の名前が入っている各参考文献項目(空白行で区切られたもの)を\ textbf {}で囲むことで手動で達成できます。文字列を含む段落をテキストで囲みます。

このプロセスを自動化する方法はありますか?たぶんawkを使用していますか?以下は、私の元のテキストの短い例と、私がそれを変更したい方法です(最後に\ textbf {に続き、の最後のをメモしてください)。

ありがとうございました! ロバート

%---- ORIGINAL FILE ----% 

\begin{thebibliography}{} 

\bibitem [\protect \citeauthoryear {% 
Aagaard% 
\ \BBA {} Andersen% 
}{% 
Aagaard% 
\ \BBA {} Andersen% 
}{% 
{\protect \APACyear {1998}}% 
}]{% 
Aagaard:1998aa} 
\APACinsertmetastar {% 
Aagaard:1998aa}% 
\begin{APACrefauthors}% 
Aagaard, P.% 
\BCBT {}\ \BBA {} Andersen, J\BPBI L.% 
\end{APACrefauthors}% 
\unskip\ 
\newblock 
\APACrefYearMonthDay{1998}{Aug}{}. 
\newblock 
{\BBOQ}\APACrefatitle {Correlation between contractile strength and myosin 
    heavy chain isoform composition in human skeletal muscle} {Correlation 
    between contractile strength and myosin heavy chain isoform composition in 
    human skeletal muscle}.{\BBCQ} 
\newblock 
\APACjournalVolNumPages{Med Sci Sports Exerc}{30}{8}{1217-22}. 
\PrintBackRefs{\CurrentBib} 

\bibitem [\protect \citeauthoryear {% 
Young% 
, Stokes% 
\BCBL {}\ \BBA {} Crowe% 
}{% 
Young% 
\ \protect \BOthers {.}}{% 
{\protect \APACyear {1985}}% 
}]{% 
Young:1985aa} 
\APACinsertmetastar {% 
Young:1985aa}% 
\begin{APACrefauthors}% 
Young, A.% 
, Stokes, M.% 
\BCBL {}\ \BBA {} Crowe, M.% 
\end{APACrefauthors}% 
\unskip\ 
\newblock 
\APACrefYearMonthDay{1985}{Apr}{}. 
\newblock 
{\BBOQ}\APACrefatitle {The size and strength of the quadriceps muscles of old 
    and young men} {The size and strength of the quadriceps muscles of old and 
    young men}.{\BBCQ} 
\newblock 
\APACjournalVolNumPages{Clin Physiol}{5}{2}{145-54}. 
\PrintBackRefs{\CurrentBib} 

\end{the bibliography} 

%---- MODIFIED FILE ----% 

\begin{thebibliography}{} 

\bibitem [\protect \citeauthoryear {% 
Aagaard% 
\ \BBA {} Andersen% 
}{% 
Aagaard% 
\ \BBA {} Andersen% 
}{% 
{\protect \APACyear {1998}}% 
}]{% 
Aagaard:1998aa} 
\APACinsertmetastar {% 
Aagaard:1998aa}% 
\begin{APACrefauthors}% 
Aagaard, P.% 
\BCBT {}\ \BBA {} Andersen, J\BPBI L.% 
\end{APACrefauthors}% 
\unskip\ 
\newblock 
\APACrefYearMonthDay{1998}{Aug}{}. 
\newblock 
{\BBOQ}\APACrefatitle {Correlation between contractile strength and myosin 
    heavy chain isoform composition in human skeletal muscle} {Correlation 
    between contractile strength and myosin heavy chain isoform composition in 
    human skeletal muscle}.{\BBCQ} 
\newblock 
\APACjournalVolNumPages{Med Sci Sports Exerc}{30}{8}{1217-22}. 
\PrintBackRefs{\CurrentBib} 

\textbf{\bibitem [\protect \citeauthoryear {% 
Young% 
, Stokes% 
\BCBL {}\ \BBA {} Crowe% 
}{% 
Young% 
\ \protect \BOthers {.}}{% 
{\protect \APACyear {1985}}% 
}]{% 
Young:1985aa} 
\APACinsertmetastar {% 
Young:1985aa}% 
\begin{APACrefauthors}% 
Young, A.% 
, Stokes, M.% 
\BCBL {}\ \BBA {} Crowe, M.% 
\end{APACrefauthors}% 
\unskip\ 
\newblock 
\APACrefYearMonthDay{1985}{Apr}{}. 
\newblock 
{\BBOQ}\APACrefatitle {The size and strength of the quadriceps muscles of old 
    and young men} {The size and strength of the quadriceps muscles of old and 
    young men}.{\BBCQ} 
\newblock 
\APACjournalVolNumPages{Clin Physiol}{5}{2}{145-54}. 
\PrintBackRefs{\CurrentBib}} 

\end{the bibliography} 
+0

あるよう)

1印刷レコードを接頭辞と接尾辞を引用して、次のレコードにスキップ - http://tex.stackexchange.com/q/149743/50142は手がかりを含んでいるようです。 –

答えて

0

awkレスキュー!私はあなたがマークアップの問題を持っていると思うが、これは偽陽性がある場合は、あなたがチューニングパターンマッチングを細かくすることができます大胆なラッピング

$ awk -v RS= -v ORS="\n\n" '/bibitem/ && /Crowe/{print "\\textbf{" $0 "}"; next}1' file 

を行います。

説明

-v RS=段落モードを設定し、これらの二つのパターンがで見つかった場合、レコードが一つ以上の空白行で区切られた

ORS="\n\n"レコード

/bibitem/ && /Crowe/との間に空白行で出力を正規化しますレコード...

print "\\textbf{" $0 "}"; nextラップ現在のレコード(012私はラテックスの中にこれを行うには、より堅牢なことと思う

+0

ありがとう、karakfa、これはほぼ完璧に動作します。唯一の問題は、今では私の各出版物の前に改行が追加されていることです。なぜそれが事実なのか?また、上記のことが実際に何をしているのかを簡単に説明できますか? ORSによる –

+0

の場合、最後に余分な行が追加されます。レコード間に余分な空白があってはいけません。最後の空白行は、 'sed '$ {/^$/d}'' – karakfa

+0

にパイプして削除することができます。将来私はコードを再現することができないため、書き留めておく必要があります。太字で強調表示されているビブ項目の前にある空白行は、ラテックスのものでもかまいません。書誌ファイルの空白行をすべて削除し、 grepで新しいファイルにパイプするだけです。 filename> filename_new は結局私が望む結果を私にくれました。 –

関連する問題