\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 回答2

1
```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} ```
  • 非常感谢! – a0000 2019-11-03 09:32 回复
2
可以用`p{...}`单元格: ``` \begin{tabular}{c|p{6cm}} \hline name & direction \\\hline a1 & N-SL \\\hline & \begin{verbatim} #include <iostream> int main() { std::cout << "Hello, world!" << std::endl; return 0; } \end{verbatim} \end{tabular} ```

你的回答

请登录后回答

你的回答将会帮助更多人,请务必认真回答问题。