LaTeXStudio
LaTeXStudio
这家伙很懒,什么也没写!

注册于 4年前

回答
492
文章
308
关注者
211

使用命令行要切换到pdf所在的路径,这样命令行才能找到这个 PDF 文件。

没有细看说明书的问题,主要是 verb 命令引起的问题,看说明书这里:
image.png

代码改成这样:

\begin{table}
  \centering
  \caption{自定义命令}
  \begin{tblr}{verb,colspec={lc}}
  \hline\hline
  命令 & 结果 \\
  \hline
  \verb|\whiteding{8}|  & \whiteding{8}  \\
  \verb|\blackding{8}|  & \blackding{8}  \\
  \verb|\whitedingB{8}| & \whitedingB{8} \\
  \verb|\blackdingB{8}| & \blackdingB{8} \\
  \hline\hline
  \end{tblr}
\end{table}

image.png

这种用表格呗,上下居中对齐,时间这都是打印出来再签字扫描进去。

肯定你是加了什么字体宏包干扰了模板自带的字体效果了。自己删删代码。

多下标的场景,要注意用群组:

\begin{equation}
{C_m = D_{m_1}, D_{m_2}, ..., D_{m_{k_m}}}
\end{equation}

给个两个的样例,举一反三:

\documentclass{ctexart}
\usepackage{calc}
\usepackage{tikz} 
\begin{document}


\begin{tabular}{|c|c|p{30pt}|p{30pt}|p{30pt}|}
\hline
\multicolumn{2}{|c|}{%
$\vcenter{\hbox{%
\begin{tikzpicture}
\path[use as bounding box] (\tabcolsep,0) rectangle (4cm-\tabcolsep,1cm);
\draw (0,1cm) -- node[auto]{化验室} node[auto,swap]{} (4cm,0);
\draw (0,1cm) -- node[auto,swap]{} (1.5cm,0);
\end{tikzpicture}%
}}$%
} &\multicolumn{3}{|c|}{室一\quad\quad 室二\quad\quad 室三}\\
\hline
\makebox[1.5cm-2\tabcolsep][c]{aaa} & bbb & ccc &ddd &eee \\
\hline
\end{tabular}
 
\end{document}

image.png

这似乎不对头,Winedt 只是编辑器,tikz 的部分只要你安装了完整的 texlive 或者 MikTeX 都自带了的。

从图上看,图片太大了,如何居中?

具体错误是什么,这样写没有什么大问题的。

代码各种漏,错。

\documentclass[a4paper,zihao=-4,UTF8]{article}
\usepackage{ctex}
\usepackage{amsmath}
\usepackage{indentfirst}
\usepackage{listings}
\lstset{language=Matlab}
\usepackage{float}
\usepackage{graphicx}
\graphicspath{{图片/}}
\usepackage{appendix}
\usepackage[table]{xcolor}
\renewcommand{\abstractname}{\zihao{3} 摘要\\}
\linespread{1.5}
\usepackage {xeCJK}
\usepackage{makecell}

\setCJKmainfont {FangSong}
% 设置正文罗马族的CJK字体,影响\rmfamily和\textrm 的字体
\setCJKsansfont {FangSong}
% 设置正文无衬线族的CJK字体,影响\sffamily和\textsf 的字体
\setCJKmonofont {FangSong}
%设置正文等宽族的CJK字体,影响\ttfamily 和 \texttt 的字体
\usepackage[center]{titlesec}
\newfontfamily\sectionef{Times New Roman}
\newCJKfontfamily\sectioncf{FangSong}
%\titleformat*{\section}{\Large\bfseries}
%\titleformat*{\subsection}{\large\bfseries}
% \titleformat{command}[shape]{format}{label}{sep}{before}[after] ,https://www.latexstudio.net/archives/7982.html


\begin{titlepage}
    \title{\fangsong }
    \author{\fangsong }
    \date{\today}
\end{titlepage}
\begin{document}
    \maketitle
    \newpage
    \begin{abstract}
        \par      某公司建筑工地开工,需要从料场配送水泥,具体各个料场的供应方案和选址亟需解决。
        \par  首先,根据供应与选址问题可以划分为规划问题.针对第一问,在给定料场位置的情况下,根据题目所给条件给出\textbf{线性规划模型},用穷举法遍历所有可能值,最终比较所有值得出最佳运输方案:
        \par 针对问题二,要改建两个新料场,因为要确定确定料场的位置和运送量,在与第一问的同样条件下。将问题二转化为\textbf{非线性规划问题}。采取二次规划的方法,利用$ matlab $的$ fmincon $函数求解,最终的方案为:\\
        
        \textbf{ 关键词}:线性规划模型、非线性规划问题、优化问题
    \end{abstract}
    
    \thispagestyle{empty}
    \newpage
    \pagenumbering{arabic}
    \begin{center}
        \tableofcontents
    \end{center}
    
    \newpage
    \section{问题重述与分析}
   某公司有6个建筑工地要开工,每个工地的位置给出。需解决两个问题:\\

   问题一:给定两个日储量20吨临时料场位于A(5,1),B(2,7)。目标是制定最佳的供应计划即考虑吨千米数在适当方案下最小\\
   问题二 :考虑建立两个新的日存储量为20吨的料场,进一步减少吨千米数
    \par

    \section{基本假设}
    由于本次是规划类问题,便于模型的建立与求解,做出以下假设。
    \par (1)从料场到工地之间均有直线道路连接。
    \par(2)建筑工地水泥用量和料场水泥日存储量均不发生改变。
    \par(3)不考虑运输过程由于道路等因素出现的影响。

    
    \section{符号说明}
    \begin{table}[H]
        \setlength{\abovecaptionskip}{0pt}
            \setlength{\belowcaptionskip}{10pt}
        %     \captionsetup{margin=10pt , font=small,
            %     labelfont=bf, labelsep=period,
            %     skip=5pt    , labelformat=empty}[ 符号一览表} %表一加粗 居中
    \setlength{\tabcolsep}{20mm}{%7可随机设置,调整到适合自己的大小为止
        \caption{符号一览表}
        \begin{tabular}{c | c}
            \hline
            符号    &   \quad 含义 \\
            \rowcolor{black!20}    
        $f$    &    总的吨千米数 \\
            \hline     \rowcolor{black!5}    
                $ x_i$ &     临时料场的横坐标\\
            \rowcolor{black!20}    
            $ x_j$    &  临时料场的横坐标\\
            \rowcolor{black!5}    
        $ a_i $&  工地的横坐标\\
            \rowcolor{black!20}    
                $ b_i $&  工地的纵坐标\\
            \rowcolor{black!5}    
        $ e_j $&  日储量(吨)\\
            \rowcolor{black!20}    
                $ X_{ij} $&  运送量(吨)\\
            \rowcolor{black!5}    
        
        
            \hline
        \end{tabular}
    }
\end{table}


\setcounter{page}{1}

\section{模型的建立与求解}
\subsection{模型的建立}
记工地的位置为$ (a_i,b_i) $,水泥日用量为$ di,i=1,…,6 $;料场位置为$ (x_j,y_j) $,日储量为$e_ j,j=1,2 $;从料场$ j $向工地i的运送量为$ X_{ij} $。则由题目给出的条件给出线性规划模型:
目标函数为
\begin{equation}
    min f=\sum_{j=1}^{2}\sum_{i=1}^{6}X_ij\sqrt{(x_j-a_i)^2+(y_j-b_i)^2}
\end{equation}
约束条件:
\begin{equation}
    s.t.
    \left\{
    \begin{array}    {lr}
        \sum_{j=1}^{2}X_{ij}=d_i,i=1,2,\dots,6\\
        \sum_{j=1}^{2}X_{ij} \leq e_i,i=1,2.\\
        X_{ij}\geq 0,i=1,2,\dots,6,j=1,2.
    \end{array}
    \right.
\end{equation}
\par 同时根据两个问题的条件可设:
\\ 当用临时料场时决策变量为:$ X_{ij} $,
\\当不用临时料场时决策变量为:$ X_{ij} $,$ x_j $,$ y_j $


\subsection{模型的求解}
\subsubsection{使用临时料场的情形}
使用两个临时料场$ A(5,1),B(2,7) $.求从料场$ j $向工地$ i $的运送量为$ X_{ij} $,在各工地用量必须满足和各料场运送量不超过日储量的条件下,使总的吨千米数最小,这是线性规划问题. 线性规划模型目标函数:
\begin{equation}
min f=\sum_{j=1}^{2}\sum_{i=1}^{6}X_{ij}aa(i,j)X_{ij}
\end{equation}
约束条件:
\begin{equation}
s.t.
\left\{
\begin{array}{lr}    
    \sum_{j=1}^{2}X_{ij}=d_i,i=1,2,\dots,6\\
    \sum_{j=1}^{2}X_{ij} \leq e_i,i=1,2,\dots,6\\
\end{array}
\right.
\end{equation}
其中$aa(i,j)=\sqrt{(x_j-a_i)^2+(y_j-b_i)^2},i=1,2,\dots,j=1,2,$为常数
\\ 设 $  X_{11}=X_{1}$
, $ X_{21}= X_{ 2} $, $ X_{31}= X_{3} $
, $ X_{41}= X_{4} $
, $ X_{51}= X_{5} $,$  X_{61}= X_{6} $,
$ X_{12}= X_{7} $
, $ X_{22}= X_{8} $,$  X_{32}= X_{9} $
,$  X_{42}= X_{10} $
, $ X_{52}= X_{11} $, $ X_{62}=X_{12} $
\\使用$ fmincon $函数,求出方案为:
\begin{table}[H]
    \setlength{\tabcolsep}{4mm}{        
        \begin{tabular}{|l|c|c|c|c|c|c|}
            \hline    \rowcolor{black!20}    
            \quad&1&2&3&4&5&6\\
            \hline
            \makecell{料场A向各工地 \\运送水泥量(吨)}&3.0&5.0&0.0&7.9&0.0&1.0\\
            \hline
                \makecell{料场B向各工地 \\运送水泥量(吨)}&0.0&0.0&4.0&0.0&6.0&10.0\\
            \hline
    \end{tabular}     }

\end{table}
总的吨千米数为138.2815.

\subsubsection{改建两个新料场的情形}
改建两个新料场,要同时确定料场的位置(xj,yj)和运送量$ X_{ij} $,在同样条件下使总吨千米数最小。这是非线性规划问题。
非线性规划模型为:
\begin{equation}
    min f=\sum_{j=1}^{2}\sum_{i=1}^{6}X_{ij}\sqrt{(x_j-a_i)^2+(y_j-b_i)^2}
\end{equation}
约束条件:
\begin{equation}
    s.t.
    \left\{
    \begin{array}{lr}    
        \sum_{j=1}^{2}X_{ij}=d_i,i=1,2,\dots,6\\
        \sum_{j=1}^{2}X_{ij} \leq e_i,i=1,2,\dots,6\\
    \end{array}
    \right.
\end{equation}
设 $ X_11=X_1
, X_21= X_ 2, X_31= X_ 3
, X_41= X _4
, X_51= X_ 5,X_61= X_ 6
X_12= X _7
, X_22= X_ 8,X_32= X_ 9
, X_42= X_10
, X_52= X_11, X_62= X_12
x_1=X_13
, y_1=X_14
, x_2=X_15
, y_2=X_16 $
\par 由于位置未确定,将非线性规划模型建立起来,利用matlab的fmiincon函数对其进行求解。取第一问的料场位置及供应方案作为初值,最终得到求值结果:
\begin{table}[H]
        \setlength{\tabcolsep}{1mm}{
            \begin{tabular}{|l|c|c|c|c|c|c|}
                \hline     \rowcolor{black!20}    
                \quad&1&2&3&4&5&6\\
                \hline
                \makecell{料场A向各工地 \\运送水泥量(吨)}&2.9308&4.6211&3.8663&6.9324&1.5444&0.0253\\
                \hline
                \makecell{料场B向各工地 \\运送水泥量(吨)}&0.0692&0.3789&0.1337&0.0676&4.556&10.9747\\
                \hline
        \end{tabular}     }
    
\end{table}
新建料场C(5.7419,4.9914)、D(7.2500,7.2500)
总的吨千米数为89.9233.




\subsubsection{改建料场方案的优化}
\par 使用$ matlab $的$ fmincon $函数,可以将第二问求出的料场位置及供应方案作为初值带入进行优化。最终得到结果:

\begin{table}[H]
     \setlength{\tabcolsep}{1mm}{
             \begin{tabular}{|l|c|c|c|c|c|c|}
             \hline     \rowcolor{black!20}    
             \quad&1&2&3&4&5&6\\
             \hline
             \makecell{料场A向各工地 \\运送水泥量(吨)}&2.9974&4.9865&3.9950&6.9972&1.0196&0.0010\\
             \hline
                 \makecell{料场B向各工地 \\运送水泥量(吨)}&0.0026& 0.0135& 0.0050& 0.0028& 4.9804& 10.9990\\
             \hline
     \end{tabular}     }

\end{table}
新建料场C(5.7419,4.9914)、D(7.2500,7.2500)
总的吨千米数为89.9233.


\section{模型的评价}
优点:可以较好应用实际情况
缺点:未必能求出全局最优解,模型的解法依赖于初值的选取。


\par 缺点:

\begin{thebibliography}{99}
    
    \bibitem{book1}姜启源,谢金星,叶俊, 《数学模型》,高等教育出版社
    
\end{thebibliography}
\begin{appendices}

    \section{附录-matlab代码}
\lstset{language = matlab,
    backgroundcolor = \color{yellow!10}, % 背景色:淡黄
    basicstyle = \small\ttfamily, % 基本样式 + 小号字体
    rulesepcolor= \color{gray}, % 代码块边框颜色
    breaklines = true, % 代码过长则换行
    numbers = left, % 行号在左侧显示
    numberstyle = \small, % 行号字体
    keywordstyle = \color{blue}, % 关键字颜色
    commentstyle =\color{green!100}, % 注释颜色
    stringstyle = \color{red!100}, % 字符串颜色
    frame = shadowbox, % 用(带影子效果)方框框住代码块
    showspaces = false, % 不显示空格
    columns = fixed, % 字间距固定
}
    %\lstinline[extendedchars=false]    
    %escapeinside={} % 特殊自定分隔符:
 \begin{lstlisting}
    第一问:
    模型:
        function f=fun(X)
        a=[1.25 8.75 0.5 5.75 3 7.25];%各工地位置的横坐标;
        b=[1.25 0.75 4.75 5 6.5 7.25];%各工地位置的纵坐标;
        x1=5*ones(1,6);
        y1=ones(1,6);
        x2=2*ones(1,6);
        y2=7*ones(1,6);
        f=sqrt((x1-a).^2+(y1-b).^2)*[X(1) X(2) X(3) X(4) X(5) X(6)]'+sqrt((x2-a).^2+(y2-b).^2)*[X(7) X(8) X(9) X(10) X(11) X(12)]';
        %X1,X2,X3,X4,X5,X6为新建料场A(5,1)向各工地运送的水泥吨数;
        %X6.X7.X8.X9.X10,X11,X12为新建料场B(2,7)向各工地运送的水泥吨数;
        求解:
        e1=20;e2=20;%料场水泥日储量
        d=[3 5 4 7 6 11];%各个工地水泥日用量
        x0=ones(12,1);%初值
        A=[1 1 1 1 1 1 0 0 0 0 0 0;0 0 0 0 0 0 1 1 1 1 1 1];
        b=[e1;e2];
        Aeq=[1 0 0 0 0 0 1 0 0 0 0 0;0 1 0 0 0 0 0 1 0 0 0 0;0 0 1 0 0 0 0 0 1 0 0 0;0 0 0 1 0 0 0 0 0 1 0 0;0 0 0 0 1 0 0 0 0 0 1 0;0 0 0 0 0 1 0 0 0 0 0 1]
        beq=d';
        VLB=zeros(12,1);
        VUB=[d';d'];
        [x,fval]=fmincon('fun',x0,A,b,Aeq,beq,VLB,VUB)
        第二问:
        模型:
        function f=fun1(X)
        a=[1.25 8.75 0.5 5.75 3 7.25];%各工地位置的横坐标;
        b=[1.25 0.75 4.75 5 6.5 7.25];%各工地位置的纵坐标;
        f=X(1)*sqrt((X(13)-a(1))^2+(X(14)-b(1))^2)+X(2)*sqrt((X(13)-a(2))^2+(X(14)-b(2))^2)+X(3)*sqrt((X(13)-a(3))^2+(X(14)-b(3))^2)+X(4)*sqrt((X(13)-a(4))^2+(X(14)-b(4))^2)+X(5)*sqrt((X(13)-a(5))^2+(X(14)-b(5))^2)+X(6)*sqrt((X(13)-a(6))^2+(X(14)-b(6))^2)+X(7)*sqrt((X(15)-a(1))^2+(X(16)-b(1))^2)+X(8)*sqrt((X(15)-a(2))^2+(X(16)-b(2))^2)+X(9)*sqrt((X(15)-a(3))^2+(X(16)-b(3))^2)+X(10)*sqrt((X(15)-a(4))^2+(X(16)-b(4))^2)+X(11)*sqrt((X(15)-a(5))^2+(X(16)-b(5))^2)+X(12)*sqrt((X(15)-a(6))^2+(X(16)-b(6))^2);
        %X1,X2,X3,X4,X5,X6为新建料场A(5,1)向各工地运送的水泥吨数;
        %X6.X7.X8.X9.X10,X11,X12为新建料场B(2,7)向各工地运送的水泥吨数;
        求解:
        e1=20;e2=20;%料场水泥日储量
        d=[3 5 4 7 6 11];%各个工地水泥日用量
        x0=[3 5 0 7 0 1 0 0 4 0 6 10 5 1 2 7];%初值取(1)的结果和临时料场的坐标
        A=[1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0];
        b=[e1;e2];
        Aeq=[1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0;0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0;0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0;0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0;0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0];
        beq=d';
        VLB=zeros(16,1);
        VUB=[];
        [x,fval]=fmincon('fun1',x0,A,b,Aeq,beq,VLB,VUB)
        x1=[2.9308 4.6211 3.8663 6.9324 1.5444 0.0253 0.0692 0.3789 0.1337 0.0676 4.4556 10.9747 5.7419 4.9914 7.2500 7.2500]%初值取的是上面计算结果
        [y,fvaly]=fmincon('fun1',x1,A,b,Aeq,beq,VLB,VUB)
    \end{lstlisting}
\end{appendices}
\end{document} 

我这里测试的样例是没有问题的,可以看看下面的例子:
image.png

例子代码:
0426.zip

仔细看看说明书,提到了的,label 后面要加上 % 来规避空格。

\documentclass[twocolumn]{article}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{showframe}
\title{The Dog}

\begin{document}

The dog or domestic dog (Canis familiaris or Canis lupus familiaris) is a domesticated descendant of the wolf, and is characterized by an upturning tail. The dog is derived from an ancient, extinct wolf, and the modern wolf is the dog's nearest living relative. The dog was the first species to be domesticated, by hunter–gatherers over 15,000 years ago, before the development of agriculture. Due to their long association with humans, dogs have expanded to a large number of domestic individuals and gained the ability to thrive on a starch-rich diet that would be inadequate for other canids.

The dog has been selectively bred over millennia for various behaviors, sensory capabilities, and physical attributes. Dog breeds vary widely in shape, size, and color. They perform many roles for humans, such as hunting, herding, pulling loads, protection, assisting police and the military, companionship, therapy, and aiding disabled people. Over the millennia, dogs became uniquely adapted to human behavior, and the human-canine bond has been a topic of frequent study. This influence on human society has given them the sobriquet of "man's best friend".

The dog or domestic dog (Canis familiaris or Canis lupus familiaris) is a domesticated descendant of the wolf, and is characterized by an upturning tail. The dog is derived from an ancient, extinct wolf, and the modern wolf is the dog's nearest living relative. The dog was the first species to be domesticated, by hunter–gatherers over 15,000 years ago, before the development of agriculture. Due to their long association with humans, dogs have expanded to a large number of domestic individuals and gained the ability to thrive on a starch-rich diet that would be inadequate for other canids.

\begin{figure}[!t]
    \subfigure[]{%
        \begin{minipage}[b]{\columnwidth}
            \centering
            \label{fig_test_case1:a}%
            \includegraphics[width=\columnwidth]{dog.jpeg}
        \end{minipage}
    }\\
    \subfigure[]{%
        \begin{minipage}[b]{\columnwidth}
            \centering
            \label{fig_test_case1:b}%
            \includegraphics[width=\columnwidth]{dog.jpeg}
        \end{minipage}
    }
    \caption{The dog or domestic dog is a domesticated descendant of the wolf. (a) Dog 1; (b) Dog 2.}
    \label{fig_test_case1}
\end{figure}

The dog has been selectively bred over millennia for various behaviors, sensory capabilities, and physical attributes. Dog breeds vary widely in shape, size, and color. They perform many roles for humans, such as hunting, herding, pulling loads, protection, assisting police and the military, companionship, therapy, and aiding disabled people. Over the millennia, dogs became uniquely adapted to human behavior, and the human-canine bond has been a topic of frequent study. This influence on human society has given them the sobriquet of "man's best friend".

The dog or domestic dog (Canis familiaris or Canis lupus familiaris) is a domesticated descendant of the wolf, and is characterized by an upturning tail. The dog is derived from an ancient, extinct wolf, and the modern wolf is the dog's nearest living relative. The dog was the first species to be domesticated, by hunter–gatherers over 15,000 years ago, before the development of agriculture. Due to their long association with humans, dogs have expanded to a large number of domestic individuals and gained the ability to thrive on a starch-rich diet that would be inadequate for other canids.

\end{document}

image.png

发布
问题