在此文档中,\VerbatimInput
正在调用test_2.dat
。
test_2.dat
包含一行太长,因此编译生成的 pdf 中该行不完整:
通过使用adjustbox
,可以调整逐字文本:
\begin{adjustbox}{max width=\linewidth}
\begin{BVerbatim}
text
\end{BVerbatim}
\end{adjustbox}
然而,此解决方案仅在文本直接逐字引入时才有效。
我必须使用,\VerbatimInput
因为我需要调用这个tesst_2.dat
文件。
有没有办法包含adjustbox
在里面\VerbatimInput
?
或者有什么解决方案可以缩小此文\VerbatimInput
本?
这些是.tex
和test_2.dat
文件:
\documentclass[12pt]{article}
\usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{fancyvrb}
\usepackage{color,soul}
\usepackage[dvipsnames]{xcolor}
\begin{document}
\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}%
{fontsize=\footnotesize,
%
frame=lines, % top and bottom rule only
framesep=2em, % separation between frame and text
rulecolor=\color{Gray},
%
label=\fbox{\color{Black}test.dat},
labelposition=topline,
%
%commandchars=\|\(\), % escape character and argument delimiters for
% commands within the verbatim
%commentchar=* % comment character
}
\VerbatimInput{./test_2.dat}
\end{document}
文件test_2.dat
:
#####l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220
14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220
14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220
14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220
14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220
14.756876 # -> reorientation volumregfddfg
#l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg
#l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg
####l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg
#l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg
#l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg
#####l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg
####l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg
####l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg
#l.253:
AL BL LC AA BB CC E
2.75319 2.75319 2.75319 60.67009 65.70804 68.04220 14.756876 # -> reorientation volumregfddfg
新编辑:根据@egreg 的评论:
\BVerbatimInput
我在里面使用\begin{adjustbox}
,如下所示,但这会生成一个没有分页符的 pdf,并且文件的其余内容test_2.dat
不会出现:
有没有办法让test_2.dat
文件正常显示:-让test_2.dat
文件占用所需的尽可能多的 pdf 页面-?
\documentclass[12pt]{article}
\usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{adjustbox}
\usepackage{fancyvrb}
\usepackage{color,soul}
\usepackage[dvipsnames]{xcolor}
\begin{document}
\begin{adjustbox}{max width=\linewidth}
\RecustomVerbatimCommand{\BVerbatimInput}{BVerbatimInput}%
{fontsize=\footnotesize,
%
frame=lines, % top and bottom rule only
framesep=2em, % separation between frame and text
rulecolor=\color{Gray},
%
label=\fbox{\color{Black}test.dat},
labelposition=topline,
%
%commandchars=\|\(\), % escape character and argument delimiters for
% commands within the verbatim
%commentchar=* % comment character
}
\BVerbatimInput{./test_2.dat}
\end{adjustbox}
\end{document}
答案1
我看不出有什么“自动”的方法,但你可以轻松地调整字体大小:在你的设置中,
\fontsize{7}{9}\selectfont
很好。
\documentclass[12pt]{article}
\usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{fancyvrb}
\usepackage{color,soul}
\usepackage[dvipsnames]{xcolor}
\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}{
fontsize=\footnotesize % default
%
frame=lines, % top and bottom rule only
framesep=2em, % separation between frame and text
rulecolor=\color{Gray},
%
label=\fbox{\color{Black}test.dat},
labelposition=topline,
%
%commandchars=\|\(\), % escape character and argument delimiters for
% commands within the verbatim
%commentchar=* % comment character
}
\begin{document}
\VerbatimInput[fontsize=\fontsize{7}{9}\selectfont]{\jobname.dat}
\end{document}
您可能需要添加
\RequirePackage{fix-cm}
\documentclass
如果您想要更精细地控制字体大小,请将其放置在文档的最顶部,之前。
答案2
这里有一些使用的可能性verbatimbox
。
\documentclass[12pt]{article}
\usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{fancyvrb}
\usepackage{color,soul}
\usepackage[dvipsnames]{xcolor}
\usepackage{verbatimbox}
\begin{document}
\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}%
{fontsize=\footnotesize,
%
frame=lines, % top and bottom rule only
framesep=2em, % separation between frame and text
rulecolor=\color{Gray},
%
label=\fbox{\color{Black}test.dat},
labelposition=topline,
%
%commandchars=\|\(\), % escape character and argument delimiters for
% commands within the verbatim
%commentchar=* % comment character
}
% \VerbatimInput{./test_2.dat}
%\clearpage
\noindent\hrulefill\raisebox{-2pt}{\fbox{\color{Black}shifted test.dat}}\hrulefill
\verbfilenobox[\leavevmode\kern-35pt\scriptsize]{./test_2.dat}
\clearpage
\noindent\hrulefill\raisebox{-2pt}{\fbox{\color{Black}blank lines retained tiny test.dat}}\hrulefill
\verbfilenobox[\leavevmode\tiny]{./test_2.dat}
\clearpage
\noindent\hrulefill\raisebox{-2pt}{\fbox{\color{Black}tiny test.dat}}\hrulefill
\verbfilenobox[\tiny]{./test_2.dat}
\clearpage
\noindent\hrulefill\raisebox{-2pt}{\fbox{\color{Black}too wide test.dat}}\hrulefill
\verbfilenobox{./test_2.dat}
\end{document}