表格里如何添加代码?

2019-11-03 08:35发布

\documentclass{article} \begin{document} \begin{tabular}{c|c} \hline name & direction \\ \hline a...

\documentclass{article} \begin{document} \begin{tabular}{c|c} \hline name & direction \\ \hline a1 & N-SL \\ \hline \end{tabular} \begin{verbatim} #include int main() { std::cout << "Hello, world!" << std::endl; return 0; } \end{verbatim} \end{document} ![怎样把代码片段放到a1的位置上?](https://pics.latexstudio.net/data/images/201911/7ba6c3da2d969e7.png "怎样把代码片段放到a1的位置上?")
2条回答
合肥-Renascence_5
2019-11-03 09:31 .采纳回答
```tex \documentclass{article} \usepackage{varwidth} \begin{document} \begin{tabular}{c|c} \hline name & direction \\ \hline a1 & N-SL \\ \hline \begin{varwidth}{10cm}%\vspace*{0.5mm} \begin{verbatim} include int main() { std::cout << “Hello, world!” << std::endl; return 0; } \end{verbatim} \end{varwidth} &rrr\\ \hline \end{tabular} \end{document} ```

一周热门 更多>