Problem aligning two alphabets
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format.
I would use the tabular
environment and a monospace font.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
&\text{Plaintext:\;\;\; }\text{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}\\
&\text{Ciphertext: }\;\text{Z Y X W V U T S R Q P O N M L K J I H G F E D C B A}
\end{align*}
\noindent\begin{tabular}{ll}
Plaintext: & \texttt{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}\\
Ciphertext: & \texttt{Z Y X W V U T S R Q P O N M L K J I H G F E D C B A}
\end{tabular}
\end{document}
If you don't want to change font, you might use something like this:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{array,tabularx,rotating}
\begin{document}
\begin{sidewaystable}
\centering\setlength\tabcolsep{2.5pt}%
\begin{tabularx}\linewidth{l*{26}X}
Plaintext: &A &B &C &D &E &F &G &H &I &J &K &L &M &N &O &P &Q &R &S &T &U &V &W &X &Y &Z\\
Ciphertext: &Z &Y &X &W &V &U &T &S &R &Q &P &O &N &M &L &K &J &I &H &G &F &E &D &C &B &A\\
\end{tabularx}
\end{sidewaystable}
\end{document}
A tabular
is better; one can also go the extra mile and simplify the input. With w{c}{1em}
we get a fixed width cell; I also set the intercolumn space to zero, because in this application it's not needed.
The \tl_map_function:nN
instruction splits the first argument into tokens and applies to each one the specified function, whose duty here is to add &
in front of the letter.
\documentclass{article}
\usepackage{xparse,array}
\ExplSyntaxOn
\NewDocumentCommand{\cipher}{m}
{% #1 = a permutation of 26 letters
\deadlingo_cipher:n { #1 }
}
\cs_new_protected:Nn \deadlingo_cipher:n
{
\group_begin:
\setlength{\tabcolsep}{0pt}
\begin{tabular}{l@{\hspace{1em}}*{26}{w{c}{1em}}}
Plaintext:
\tl_map_function:nN {ABCDEFGHIJKLMNOPQRSTUVWXYZ} \__deadlingo_cipher_cell:n \\
Ciphertext:
\tl_map_function:nN {#1} \__deadlingo_cipher_cell:n \\
\end{tabular}
\group_end:
}
\cs_new:Nn \__deadlingo_cipher_cell:n { & #1 }
\ExplSyntaxOff
\begin{document}
Here is one cipher
\begin{center}
\cipher{Z Y X W V U T S R Q P O N M L K J I H G F E D C B A}
\end{center}
and here's another one, usually called ROT13,
\begin{center}
\cipher{N O P Q R S T U V W X Y Z A B C D E F G H I J K L M}
\end{center}
\end{document}
If you prefer a monospaced font:
\documentclass{article}
\usepackage{xparse,array}
\ExplSyntaxOn
\NewDocumentCommand{\cipher}{m}
{% #1 = a permutation of 26 letters
\deadlingo_cipher:n { #1 }
}
\cs_new_protected:Nn \deadlingo_cipher:n
{
\group_begin:
\setlength{\tabcolsep}{0pt}\ttfamily
\begin{tabular}{l@{\hspace{1em}}*{26}{w{c}{1em}}}
\normalfont Plaintext:
\tl_map_function:nN {ABCDEFGHIJKLMNOPQRSTUVWXYZ} \__deadlingo_cipher_cell:n \\
\normalfont Ciphertext:
\tl_map_function:nN {#1} \__deadlingo_cipher_cell:n \\
\end{tabular}
\group_end:
}
\cs_new:Nn \__deadlingo_cipher_cell:n { & #1 }
\ExplSyntaxOff
\begin{document}
Here is one cipher
\begin{center}
\cipher{Z Y X W V U T S R Q P O N M L K J I H G F E D C B A}
\end{center}
and here's another one, usually called ROT13,
\begin{center}
\cipher{N O P Q R S T U V W X Y Z A B C D E F G H I J K L M}
\end{center}
\end{document}