Ausrichten von Schreibmaschinentext in verschiedenen Zeilen

Ausrichten von Schreibmaschinentext in verschiedenen Zeilen

Ich stelle eine Tabelle mit Buchstaben und Zahlen unter den Buchstaben zusammen, um den Fortschritt zu verfolgen.

\documentclass{article}
\usepackage{xcolor, placeins, cmbright}
\usepackage[margin=0.5in]{geometry}
\begin{document}
\small
\begin{tabular}{|c|c|c|} \hline
S & \texttt{\textcolor{gray}{E}\textcolor{teal}{T}\textcolor{teal}{M}\textcolor{teal}{W}\textcolor{green}{D}\textcolor{gray}{T}\textcolor{green}{K}\textcolor{teal}{K}\textcolor{teal}{E}\textcolor{green}{V}\textcolor{gray}{K}\textcolor{teal}{A}\textcolor{teal}{A}\textcolor{teal}{A}\textcolor{teal}{T}\textcolor{gray}{A}\textcolor{teal}{A}\textcolor{teal}{M}\textcolor{teal}{T}\textcolor{teal}{K}\textcolor{gray}{A}\textcolor{teal}{T}\textcolor{teal}{E}\textcolor{teal}{T}\textcolor{teal}{V}\textcolor{gray}{D}\textcolor{green}{N}\textcolor{teal}{K}\textcolor{green}{D}\textcolor{teal}{I}\textcolor{gray}{E}\textcolor{teal}{R}\textcolor{teal}{F}\textcolor{teal}{I}\textcolor{green}{P}\textcolor{gray}{S}\textcolor{teal}{L}\textcolor{teal}{I}\textcolor{teal}{Q}\textcolor{teal}{C}\textcolor{gray}{I}\textcolor{teal}{A}\textcolor{teal}{D}\textcolor{green}{P}\textcolor{teal}{T}E-\textcolor{gray}{-}\textcolor{teal}{V}\textcolor{teal}{P}\textcolor{teal}{E}\textcolor{teal}{T}\textcolor{gray}{V}\textcolor{teal}{H}\textcolor{teal}{L}\textcolor{green}{L}\textcolor{teal}{G}\textcolor{gray}{A}\textcolor{green}{T}\textcolor{green}{T}\textcolor{green}{F}\textcolor{green}{V}\textcolor{gray}{A}\textcolor{teal}{E}\textcolor{green}{V}\textcolor{teal}{T}\textcolor{teal}{P}\textcolor{gray}{A}\textcolor{teal}{T}\textcolor{green}{L}\textcolor{teal}{S}\textcolor{teal}{I}\textcolor{gray}{M}\textcolor{teal}{V}\textcolor{green}{P}\textcolor{teal}{L}\textcolor{green}{L}\textcolor{gray}{S}\textcolor{teal}{R}\textcolor{teal}{G}\textcolor{green}{L}\textcolor{teal}{N}\textcolor{gray}{E}\textcolor{teal}{R}E\textcolor{teal}{-}T-\textcolor{teal}{-}\textcolor{teal}{G}\textcolor{gray}{I}\textcolor{teal}{K}\textcolor{green}{R}\textcolor{teal}{K}\textcolor{teal}{S}\textcolor{gray}{A}\textcolor{teal}{V}\textcolor{teal}{I}\textcolor{teal}{I}\textcolor{teal}{D}} & 270
\\
S track & \texttt{176   -181   -186   -191   -196   -201   -206   -211   -216   ---221   -226   -231   -236   -241   -246   -251   -256   --259   -264   -269} & 270
\\
\hline\end{tabular}
\end{document}

was zu folgendem Ergebnis führt:

Bildbeschreibung hier eingeben

aber wie Sie sehen, ist der Text in beiden Spalten nicht ausgerichtet.

Um es klarzustellen: 1Es sollte direkt unter dem Eobigen stehen. Es ist jedoch leicht nach links verschoben. 269Außerdem wird es an der falschen Stelle angezeigt.

Das Problem ist, dass Leerzeichen unterschiedlich behandelt werden, sogar bei der Monospace-\texttt

Ich habe Lösungen von vielen verschiedenen Stellen ausprobiert, wie zum BeispielÜber mehrere Zeilen in der Tabelle ausrichten(nicht der einzige Ort), aber ich weiß nicht, wie ich die Zahlen ausrichten kann.

Ich habe versucht, die Buchstaben und Zahlen in einer 100 Spalten breiten Zelle in der großen Tabelle unterzubringen, aber zwischen den Buchstaben war zu viel Platz und die Tabelle wurde unleserlich.

Ich habe es auch versucht, flushleftaber das hat nicht funktioniert.

Gibt es eine Möglichkeit, LaTeX anzuweisen, das 1direkt unter das einzufügen E?

Ich hatte etwas Glück mit der Verwendung lauf der Mittelsäule, aber mit der rechten Seite der Mittelsäule scheint das nicht zu funktionieren.

Ich bin für eine komplette Neugestaltung offen, solange das fertige Produkt gut aussieht.

Antwort1

Sie haben nicht die gleiche Anzahl von Elementen in den beiden Zeilen, was die Hauptursache für die Fehlausrichtung ist. In der ersten Zeile stehen 100 Zeichen und in der zweiten Zeile 101 (wenn Sie die Leerzeichen mit einbeziehen). Hier ist eine wortwörtliche Darstellung:

ETMWDTKKEVKAAATAAMTKATETVDNKDIERFIPSLIQCIADPTE--VPETVHLLGATTFVAEVTPATLSIMVPLLSRGLNERE-T--GIKRKSAVIID
176 -181 -186 -191 -196 -201 -206 -211 -216 ---221 -226 -231 -236 -241 -246 -251 -256 --259 -264 -269

Am besten schreiben Sie Ihren Code neu, damit er lesbarer wird und Sie die Fehler besser isolieren können. Ich bin mit dem Inhalt nicht vertraut und habe ihn daher in Breiten unterteilt, die den Zahlen entsprechen.

\documentclass{article}

\usepackage{xcolor, cmbright}
\usepackage[margin=0.5in]{geometry}

\begin{document}

\small
\begin{tabular}{ | c | l | c | }
  \hline
  S & \ttfamily
      \textcolor{gray}{E}\textcolor{teal}{T}\textcolor{teal}{M}%
      \textcolor{teal}{W}\textcolor{green}{D}\textcolor{gray}{T}\textcolor{green}{K}%
      \textcolor{teal}{K}\textcolor{teal}{E}\textcolor{green}{V}\textcolor{gray}{K}%
      \textcolor{teal}{A}\textcolor{teal}{A}\textcolor{teal}{A}\textcolor{teal}{T}%
      \textcolor{gray}{A}\textcolor{teal}{A}\textcolor{teal}{M}\textcolor{teal}{T}%
      \textcolor{teal}{K}\textcolor{gray}{A}\textcolor{teal}{T}\textcolor{teal}{E}%
      \textcolor{teal}{T}\textcolor{teal}{V}\textcolor{gray}{D}\textcolor{green}{N}%
      \textcolor{teal}{K}\textcolor{green}{D}\textcolor{teal}{I}\textcolor{gray}{E}%
      \textcolor{teal}{R}\textcolor{teal}{F}\textcolor{teal}{I}\textcolor{green}{P}%
      \textcolor{gray}{S}\textcolor{teal}{L}\textcolor{teal}{I}\textcolor{teal}{Q}%
      \textcolor{teal}{C}\textcolor{gray}{I}\textcolor{teal}{A}\textcolor{teal}{D}%
      \textcolor{green}{P}\textcolor{teal}{T}E-%
      \textcolor{gray}{-}\textcolor{teal}{V}\textcolor{teal}{P}\textcolor{teal}{E}%
      \textcolor{teal}{T}\textcolor{gray}{V}\textcolor{teal}{H}\textcolor{teal}{L}%
      \textcolor{green}{L}\textcolor{teal}{G}\textcolor{gray}{A}\textcolor{green}{T}%
      \textcolor{green}{T}\textcolor{green}{F}\textcolor{green}{V}\textcolor{gray}{A}%
      \textcolor{teal}{E}\textcolor{green}{V}\textcolor{teal}{T}\textcolor{teal}{P}%
      \textcolor{gray}{A}\textcolor{teal}{T}\textcolor{green}{L}\textcolor{teal}{S}%
      \textcolor{teal}{I}\textcolor{gray}{M}\textcolor{teal}{V}\textcolor{green}{P}%
      \textcolor{teal}{L}\textcolor{green}{L}\textcolor{gray}{S}\textcolor{teal}{R}%
      \textcolor{teal}{G}\textcolor{green}{L}\textcolor{teal}{N}\textcolor{gray}{E}%
      \textcolor{teal}{R}E\textcolor{teal}{-}T%
      -\textcolor{teal}{-}\textcolor{teal}{G}\textcolor{gray}{I}\textcolor{teal}{K}%
      \textcolor{green}{R}\textcolor{teal}{K}\textcolor{teal}{S}\textcolor{gray}{A}%
      \textcolor{teal}{V}\textcolor{teal}{I}\textcolor{teal}{I}\textcolor{teal}{D} & 270 \\
  S track & \ttfamily
      176~%
      -181~%
      -186~%
      -191~%
      -196~%
      -201~%
      -206~%
      -211~%
      -216~%
      ---221~%
      -226~%
      -231~%
      -236~%
      -241~%
      -246~%
      -251~%
      -256~%
      --259~%
      -264~%
      -269 & 270 \\
  \hline
\end{tabular}

\end{document}

verwandte Informationen