2010-01-05 80 views
4

,我有以下Latex環境乳膠環境:建立類似公式環境

\newcounter{txtctr}[section] \setcounter{txtctr}{0} 
\newenvironment{textex}{% This is the begin code 
    \refstepcounter{txtctr} \vspace{0.2cm} {\noindent 
    (T.\arabic{chapter}.\arabic{section}.\arabic{txtctr}): 
    }\footnotesize\vspace{-0.2cm}}{\normalsize} 

,但我想有櫃檯的權利,並在環境中的文字中間。喜歡的東西:

Canis per flumen carnem dum ferret natans 
aliamque praedam ab alio      (T1.1.1) 
Canis per flumen carnem dum ferret natans 

我想這可能需要一個minipage做了什麼?順便說一下,環境必須對verbatim環境友好。

有些Latex嚮導可以幫我嗎?

謝謝。

回答

2

我懷疑有一個包可以自動執行此操作(即編號的代碼示例),但現在沒有什麼可以想到的。

您正在使用的哪個逐字包指示您要如何執行此操作,但是像這樣垂直居中框的常規技巧是按照您的建議使用小型文件。只需適當地設置它們的寬度,並沒有太多的東西。

 
\begin{minipage}[c]{0.9\linewidth} 
    % your environment goes here 
\end{minipage}\hfill 
\begin{minipage}[c]{0.09\linewidth} 
(T.\arabic{chapter}.\arabic{section}.\arabic{txtctr})% 
\end{minipage} 
1

嘗試和調整了這一點:

\documentclass{article} 

\newcounter{txtctr}%Defines couter 
\def\thetxtctr{\thesection-\arabic{txtctr}}%Typesets counter 

\newenvironment{textex}{% This is the begin code 
\begin{minipage}[c]{.8\textwidth}% 
}% 
{% This is ending code 
\end{minipage} 
\begin{minipage}[c]{.2\textwidth} 
\flushright\thetxtctr 
\end{minipage} 
} 
\begin{document} 

\section{hhh} 
\begin{textex} 
\begin{verbatim} 
Canis per flumen carnem dum ferret natans 
aliamque praedam ab alio 
Canis per flumen carnem dum ferret natans 
\end{verbatim} 
\end{textex} 
\end{document} 

answer of Alexey Malistov