將兩個文字列新增到框架中

將兩個文字列新增到框架中

我也是 Latex 和 Lyx 的新手。我正在嘗試在 Lyx 中創建一個包含 2 列的框架,第一列是 JSON 格式的文本,第二列是第一列行的註釋。到目前為止,我正在使用 minted 為 JSON 文字添加一些樣式,如下所示: 我有什麼 1 第一個問題是有些行太大,我可以透過手動截斷大部分內容來縮短行,因為實際上沒有必要。結果是這樣的: 我有什麼 2 我真正想要創建的是這樣的東西,但不需要手動執行,因為我必須執行多次: 我想要的是 我真的不知道我所要求的是否可以使用 LaTeX 或 Lyx,但我真的很感激任何想法。

我見過帖子,但我不知道如何正確使用我的上下文的答案

答案1

您可以設定minted允許在任何地方換行。並手動添加空白行以對齊兩側文字。看看這是不是你想要的?如果您有任何疑問,請告訴我:

\documentclass{beamer}
\usepackage{xcolor}
\usepackage{minted}

\begin{document}
\begin{frame}[fragile]{Frame Title}
\begin{columns}[t] % align text from top 
\begin{column}{0.5\linewidth}
\begin{scriptsize}
\begin{minted}[
bgcolor=lightgray!20, % add background color
breaklines, % allow line break
breakanywhere, % allow line break at anywhere
]
{c}
{
    "public_properties": {
        "name": "Name",
        "info": "Some Info Here",
        "value": 34.5
    },
    "private properties": {
        "id": "12",
        "authkey": "aVeryLongKeyThatItSProbablyTooLongToccupyOnlyOneLineAndINeedToShowOn"
        "timestamp": "20200101T23:00:00"


        "signedonclient": true
    }
}
\end{minted}
\end{scriptsize}
\end{column}
\begin{column}{0.5\textwidth}
\begin{scriptsize}
\begin{minted}[
bgcolor=lightgray!20, % add background color
breaklines, % allow line break
breakanywhere, % allow line break at anywhere
escapeinside=@@ % add empty lines using @@
]
{c}
@@
//Public properties
//This is the name
//This is a short information
//This is the actual value

//Private properties
//This is the ID
//This is a very long authentication key


//This is only the timestamp but I'm doing it very long on purpose so the line jump is noticed
//Indicates if the client is signed
@@
\end{minted}
\end{scriptsize}
\end{column}
\end{columns}
\end{frame}
\end{document}

在此輸入影像描述

相關內容