algorithm - Latex 算法环境 float.sty 未找到
问题描述
我正在尝试在 Latex 中生成算法,但不断收到相同的错误:! LaTeX Error: File 'float.sty' not found.
. 即使我在新文档中重新创建示例。
当我使用algorithm
应该允许我创建算法环境的包时会出现问题。日志文件表明 LaTeX 找不到float.sty
.
只需简单地添加\usepackage{float}
到序言中,就可以找到一个简单的解决方案。但是添加包会导致上线出错\usepackage{algorithm}
。
这是示例代码:
\documentclass{article}
\usepackage{algpseudocode,algorithm,algorithmicx}
\newcommand*\DNA{\textsc{dna}}
\newcommand*\Let[2]{\State #1 $\gets$ #2}
\algrenewcommand\algorithmicrequire{\textbf{Precondition:}}
\algrenewcommand\algorithmicensure{\textbf{Postcondition:}}
\begin{document}
\begin{algorithm}
\caption{Counting mismatches between two packed \DNA{} strings
\label{alg:packed-dna-hamming}}
\begin{algorithmic}[1]
\Require{$x$ and $y$ are packed \DNA{} strings of equal length $n$}
\Statex
\Function{Distance}{$x, y$}
\Let{$z$}{$x \oplus y$} \Comment{$\oplus$: bitwise exclusive-or}
\Let{$\delta$}{$0$}
\For{$i \gets 1 \textrm{ to } n$}
\If{$z_i \neq 0$}
\Let{$\delta$}{$\delta + 1$}
\EndIf
\EndFor
\State \Return{$\delta$}
\EndFunction
\end{algorithmic}
\end{algorithm}
解决方案
在 samcarter_is_at_toanswers.xyz 提供的帮助下,我对 LaTeX 的运作方式有了更多的了解。问题是 MiKTeX 2.9 文件由于某种原因不再存在(或者至少无法通过 LaTeX 或手动定位)。
所以我使用这个已回答的问题来指导我重新安装 MiKTeX。这解决了问题。float package
重新安装后,TeXmaker 能够下载float.sty
我需要解决由algorithm package
.
我对 LaTeX/TeXmaker/MiKTeX 几乎没有经验,而且我对计算机的技术也不是那么好。因此,如果您对问题有更好的答案/解释/理解,请告诉我。我将编辑/删除我的答案。
推荐阅读
- debugging - 使用 GDB 调试 GNU 汇编程序时使宏扩展
- kotlin - 如果第一个参数为真,则必须在函数中传递第二个参数
- python - 创建自定义模块文件节拍问题
- lua - 如何在lua中实现include保护以防止lua多次加载同一个文件?
- flutter - 在 DropDownMenuItem 中选择特定项目时出错
- javascript - for-of 循环中的属性访问有什么作用,例如“for (ab of c)”?
- rest - 如何使用 Rest Api 将“仅从客户端的图像上传到 SharePoint 自定义列表”?不在文档库中,不在图片库中
- powershell - 带有登录部分的 Powershell 中的 WebScraping
- python - 熊猫,按计数过滤
- python - 是否可以从相同的列表中生成相同的 id 但顺序不同?