병렬 알고리즘에서 라인 강조

Aug 26 2020

2 개의 알고리즘을 나란히 배치 한 2 열 라텍스 템플릿 (IEEEtran)이 있습니다.

\documentclass[10pt,conference]{article}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{xcolor}
\def\HiLi{\leavevmode\rlap{\hbox to \hsize{\color{yellow!50}\leaders\hrule height .8\baselineskip depth .5ex\hfill}}}
\begin{document}


\begin{figure*}[htbp]
\centering
 \begin{minipage}[t]{0.49\textwidth}
    
  \begin{algorithm}[H]
        \caption{Foo}
        \begin{algorithmic}[1]
            \REQUIRE $Beer$
            \HiLi \STATE $s \leftarrow HighlightThis$
            \STATE $f \leftarrow Foo()$

        \end{algorithmic}
    \end{algorithm}
 \end{minipage}
 \begin{minipage}[t]{0.49\textwidth}
    
    \begin{algorithm}[H]
        \caption{Bar}
        \begin{algorithmic}[1]
            \REQUIRE $Wine$\\
            \STATE $s \leftarrow Bar()$
            \STATE $b \leftarrow Bar1()$
        \end{algorithmic}
    \end{algorithm}
    \vfill
 \end{minipage}
\end{figure*}

\end{document}

내 목표는 "HighlightThis"라인을 강조하는 것입니다. 나는이 2 : Approach1 , TikZ Approach을 시도했습니다 .

문제는 두 가지 접근 방식 모두에서 강조 표시가 완전히 잘못 배치되는 것입니다. 접근 방식 1 결과 :

어떻게 할 수 있습니까? 당신의 도움을 주셔서 감사합니다

답변

2 vitalstatistix Aug 26 2020 at 21:30

이것이 당신이하려는 것입니까?

\ hsize 대신 \ linewidth를 사용하도록 \ HiLi 명령을 변경하고 알고리즘에서 \ HiLi 명령 배치를 이동했습니다. 아래 참조 :

\documentclass[10pt,conference]{article}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{xcolor}
\def\HiLi{\leavevmode\rlap{\hbox to \linewidth{\color{yellow!50}\leaders\hrule height .8\baselineskip depth .5ex\hfill}}}
\begin{document}


\begin{figure*}[htbp]
\centering
 \begin{minipage}[t]{0.49\textwidth}
    
  \begin{algorithm}[H]
        \caption{Foo}
        \begin{algorithmic}[1]
            \REQUIRE $Beer$
            \STATE \HiLi $s \leftarrow HighlightThis$
            \STATE $f \leftarrow Foo()$
        \end{algorithmic}
    \end{algorithm}
 \end{minipage}
 \begin{minipage}[t]{0.49\textwidth}
    
    \begin{algorithm}[H]
        \caption{Bar}
        \begin{algorithmic}[1]
            \REQUIRE $Wine$\\
            \STATE $s \leftarrow Bar()$
            \STATE $b \leftarrow Bar1()$
        \end{algorithmic}
    \end{algorithm}
    \vfill
 \end{minipage}
\end{figure*}

\end{document}