알고리즘을 작성하려고 하는데 한 페이지에 다 들어가지 않아서 두 열에 나누어서 쓰려고 합니다.
내가 작성하려는 코드는 다음과 같습니다.
\makebox[\linewidth]{
\begin{minipage}[H]{.85\textwidth}
\begin{algorithm}[H]
\caption{Point addition in projective coordinates}
\label{alg:projective_add}
\begin{algorithmic}[1]
\Require $P = (X_1 \colon Y_1 \colon Z_1), Q = (X_2 \colon Y_2 \colon Z_2), E\colon Y^2Z = X^3 -3XZ^2 + bZ^3$
\Ensure $P + Q = (X_3 \colon Y_3 \colon Z_3)$
\begin{multicols}{2}
\State $t_0 \gets X_1 \cdot X_2$
\State $t_1 \gets Y_1 \cdot Y_2$
\State $t_2 \gets Z_1 \cdot Z_2$
\State $t_3 \gets X_1 + Y_1$
\State $t_4 \gets X_2 + Y_2$
\State $t_3 \gets t_3 \cdot t_4$
\State $t_4 \gets t_0 + t_1$
\State $t_3 \gets t_3 - t_4$
\State $t_4 \gets Y_1 + Z_1$
\State $X3 \gets Y_2 + Z_2$
\State $t4 \gets t_4 \cdot X_3$
\State $X3 \gets t_1 + t_2$
\State $t4 \gets t_4 - X_3$
\State $X3 \gets X_1 + Z_1$
\State $Y3 \gets X_2 + Z_2$
\State $X_3 \gets X_3 \cdot Y_3$
\State $Y_3 \gets t_0 + t_2$
\State $Y_3 \gets X_3 - Y_3$
\State $Z_3 \gets b \cdot t_2$
\State $X_3 \gets Y_3 - Z_3$
\State $Z_3 \gets X_3 + X_3$
\State $X_3 \gets X_3 + Z_3$
\State $Z_3 \gets t_1 - X_3$
\State $X_3 \gets t_1 + X_3$
\State $Y_3 \gets b \cdot Y_3$
\State $t_1 \gets t_2 + t_2$
\State $t_2 \gets t_1 + t_2$
\State $Y_3 \gets Y_3 - t_2$
\State $Y_3 \gets Y_3 - t_0$
\State $t_1 \gets Y_3 + Y_3$
\State $Y_3 \gets t_1 + Y_3$
\State $t_1 \gets t_0 + t_0$
\State $t_0 \gets t_1 + t_0$
\State $t_0 \gets t_0 - t_2$
\State $t_1 \gets t_4 \cdot Y_3$
\State $t_2 \gets t_0 \cdot Y_3$
\State $Y_3 \gets X_3 \cdot Z_3$
\State $Y_3 \gets Y_3 + t_2$
\State $X_3 \gets t_3 \cdot X_3$
\State $X_3 \gets X_3 - t_1$
\State $Z_3 \gets t_4 \cdot Z_3$
\State $t_1 \gets t_3 \cdot t_0$
\State $Z_3 \gets Z_3 + t_1$
\end{multicols}
\end{algorithmic}
\end{algorithm}
\end{minipage}
}
하지만 이것을 시도하면 오류가 발생합니다. \Require 전에 멀티콜을 시작하면 작동하지만 그렇게 하고 싶지는 않습니다. 이미 algpseudocode와 알고리즘을 가져왔습니다. 내가 어떻게 작동하게 할 수 있는지 아는 사람이 있나요?
답변1
두 개의 별도 환경을 사용하여 나머지 명령문에서 \Require
및 구성 요소를 분할합니다 . 그런 다음 수직 조정을 통해 두 번째 것을 a 안에 포장합니다 .\Ensure
algorithmic
multicols
\documentclass{article}
\usepackage{algorithm,algpseudocode}
\usepackage{multicol}
\begin{document}
\noindent
\begin{minipage}{.85\textwidth}
\begin{algorithm}[H]
\caption{Point addition in projective coordinates}
\begin{algorithmic}
\Require $P = (X_1 \colon Y_1 \colon Z_1), Q = (X_2 \colon Y_2 \colon Z_2), E\colon Y^2Z = X^3 -3XZ^2 + bZ^3$
\Ensure $P + Q = (X_3 \colon Y_3 \colon Z_3)$
\end{algorithmic}
\vspace{-.5\baselineskip}% Adjust to suit your needs
\begin{multicols}{2}
\begin{algorithmic}[1]
\State $t_0 \gets X_1 \cdot X_2$
\State $t_1 \gets Y_1 \cdot Y_2$
\State $t_2 \gets Z_1 \cdot Z_2$
\State $t_3 \gets X_1 + Y_1$
\State $t_4 \gets X_2 + Y_2$
\State $t_3 \gets t_3 \cdot t_4$
\State $t_4 \gets t_0 + t_1$
\State $t_3 \gets t_3 - t_4$
\State $t_4 \gets Y_1 + Z_1$
\State $X3 \gets Y_2 + Z_2$
\State $t4 \gets t_4 \cdot X_3$
\State $X3 \gets t_1 + t_2$
\State $t4 \gets t_4 - X_3$
\State $X3 \gets X_1 + Z_1$
\State $Y3 \gets X_2 + Z_2$
\State $X_3 \gets X_3 \cdot Y_3$
\State $Y_3 \gets t_0 + t_2$
\State $Y_3 \gets X_3 - Y_3$
\State $Z_3 \gets b \cdot t_2$
\State $X_3 \gets Y_3 - Z_3$
\State $Z_3 \gets X_3 + X_3$
\State $X_3 \gets X_3 + Z_3$
\State $Z_3 \gets t_1 - X_3$
\State $X_3 \gets t_1 + X_3$
\State $Y_3 \gets b \cdot Y_3$
\State $t_1 \gets t_2 + t_2$
\State $t_2 \gets t_1 + t_2$
\State $Y_3 \gets Y_3 - t_2$
\State $Y_3 \gets Y_3 - t_0$
\State $t_1 \gets Y_3 + Y_3$
\State $Y_3 \gets t_1 + Y_3$
\State $t_1 \gets t_0 + t_0$
\State $t_0 \gets t_1 + t_0$
\State $t_0 \gets t_0 - t_2$
\State $t_1 \gets t_4 \cdot Y_3$
\State $t_2 \gets t_0 \cdot Y_3$
\State $Y_3 \gets X_3 \cdot Z_3$
\State $Y_3 \gets Y_3 + t_2$
\State $X_3 \gets t_3 \cdot X_3$
\State $X_3 \gets X_3 - t_1$
\State $Z_3 \gets t_4 \cdot Z_3$
\State $t_1 \gets t_3 \cdot t_0$
\State $Z_3 \gets Z_3 + t_1$
\end{algorithmic}
\end{multicols}
\vspace{-.5\baselineskip}% Adjust to suit your needs
\end{algorithm}
\end{minipage}
\end{document}